Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- Public Function FindCodeIndex(vArray As Variant, MatchValue As String) As Integer
- ''This function locates a value in a combo box returning the index or -1 if not found
- Dim lCount As Long
- Dim maxCount As Long
- Dim arrayStr As String
- On Error GoTo ErrorHandler
- maxCount = UBound(vArray)
- For lCount = 0 To maxCount
- arrayStr = vArray(1, lCount)
- If UCase$(arrayStr) = UCase$(MatchValue) Then
- FindCodeIndex = Int(lCount)
- Exit Function
- End If
- Next lCount
- FindCodeIndex = -1
- Exit Function
- ErrorHandler:
- MsgBox "Unexpected error in frmComment::FindCodeIndex()" & vbCrLf & _
- "Error Code: " & CStr(Err.Number) & " Error Desc: " & Err.Description
- Public Function FindCodeIndex(Array() As String, ByVal MatchValue As String) As Long
- Dim index As Long
- Dim upper_bound As Long
- upper_bound= UBound(Array)
- MatchValue = UCase(MatchValue)
- For index = 0 To upper_bound
- If UCase(Array(index)) = MatchValue Then
- FindCodeIndex = index
- Exit Function
- End If
- Next index
- FindCodeIndex = -1
- End Function
- Private Declare Function SendMessage Lib "User32.dll" Alias "SendMessageA" (ByVal hWnd As Long, ByVal uMsg As Long, ByRef wParam As Any, ByRef lParam As Any) As Long
- Private Const CB_FINDSTRINGEXACT As Long = &H158
- Public Function FindCodeIndex(ByRef cmb As ComboBox, ByRef sMatchValue As String) As Long
- 'This function locates a value in a combo box returning the index or -1 if not found
- FindCodeIndex = SendMessage(cmb.hWnd, CB_FINDSTRINGEXACT, ByVal -1, ByVal sMatchValue
- End Function
Add Comment
Please, Sign In to add comment