B
BobRoyAce
When the user clicks on an item in a list box I want to update other
controls on the form accordingly. When I enter the following code in the
Click event for the list box, it doesn't find a match for the selected item
(I selected second/last item in list of two items). In other words, it says
that Selected(0) and Selected(1) are both False. What am I missing?
---CODE BEGINS---
Private Sub lstUserNames_Click()
Dim i As Integer
' Figure out which user is selected
For i = 0 To lstUserNames.ListCount - 1
If lstUserNames.Selected(i) = True Then
m_sCurrentUserName = lstUserNames.Column(1, 0)
m_lCurrentUserID = GetUserIDForUserName(m_sCurrentUserName)
Exit For
End If
Next i
End Sub
controls on the form accordingly. When I enter the following code in the
Click event for the list box, it doesn't find a match for the selected item
(I selected second/last item in list of two items). In other words, it says
that Selected(0) and Selected(1) are both False. What am I missing?
---CODE BEGINS---
Private Sub lstUserNames_Click()
Dim i As Integer
' Figure out which user is selected
For i = 0 To lstUserNames.ListCount - 1
If lstUserNames.Selected(i) = True Then
m_sCurrentUserName = lstUserNames.Column(1, 0)
m_lCurrentUserID = GetUserIDForUserName(m_sCurrentUserName)
Exit For
End If
Next i
End Sub