VBcoders Guest



Don't have an account yet? Register
 


Forgot Password?



Selects an item in a combo box if it existsin Visual Basic 6

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

Rate 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

Download this snippet    Add to My Saved Code

Selects an item in a combo box if it existsin Visual Basic 6 Comments

No comments have been posted about Selects an item in a combo box if it existsin Visual Basic 6. Why not be the first to post a comment about Selects an item in a combo box if it existsin Visual Basic 6.

Post your comment

Subject:
Message:
0/1000 characters