Re: Populate A ListBox!

Tech-Archive recommends: Speed Up your PC by fixing your registry



Create New Form
Place a list box and 2 command buttons.

Insert the code below on to the for an example.

HTH

Barry

---Code---

Option Explicit

Private Function AddListItems(MyCommandButton As CommandButton)

With List1
.AddItem (MyCommandButton.Caption)
.ListIndex = 0
.Text = .List(0)
End With


End Function

Private Sub Command2_Click()

Call AddListItems(Me.Command2)

End Sub
Private Sub Command1_Click()

Call AddListItems(Me.Command1)

End Sub

Private Sub Form_Load()

Command1.Caption = "Button A"
Command2.Caption = "Button B"


End Sub

.


Quantcast