list boxes

sailboat
04-03-2005, 05:34 PM
Probably a dumb question but if you're adding items to a list box using
lstchords.additem say A, B, C and D for instance. How do you say, if A is selected then... or if B is selected in the list box then....

Fat_Lip
04-03-2005, 05:53 PM
Private Sub Command1_Click()
If List1.Text = "A" Then
MsgBox List1.Text
ElseIf List1.Text = "B" Then
MsgBox List1.Text
ElseIf List1.Text = "C" Then
MsgBox List1.Text
End If
End Sub

Private Sub Form_Load()
List1.AddItem "A"
List1.AddItem "B"
List1.AddItem "c"
End Sub

'this method is used for double clicking a listbox
Private Sub List1_DblClick()
If List1.Text = "A" Then
MsgBox List1.Text
ElseIf List1.Text = "B" Then
MsgBox List1.Text
ElseIf List1.Text = "C" Then
MsgBox List1.Text
End If
End Sub

MikeJ
04-03-2005, 05:59 PM
List1.List(List1.ListIndex) will return the selected item. Use it in a Select Case statement or an If statement. (Select Case is best for multiple items).

EZ Archive Ads Plugin for vBulletin Copyright 2006 Computer Help Forum