by Prosper Nsengiyumva (1 Submission)
Category: Miscellaneous
Compatability: Visual Basic 5.0
Difficulty: Unknown Difficulty
Originally Published: Mon 30th October 2006
Date Added: Mon 8th February 2021
Rating: (1 Votes)
Selects an item in a combo box if it existsin Visual Basic 6
Dim intLoop As Integer
'If no elements in cmbItems then exit since there
'is nothing to search for
GetComboIndex = -1
If cmbItems.ListCount = 0 Then
Exit Function
End If
'Else search for the string
For intLoop = 0 To cmbItems.ListCount
If Trim(cmbItems.List(intLoop)) = Trim(txtItem) Then
GetComboIndex = intLoop 'Item found
Exit Function
'Else
'GetComboIndex = -1 'Item not found
End If
Next intLoop
End Function