Tek-Tips is the largest IT community on the Internet today!

Members share and learn making Tek-Tips Forums the best source of peer-reviewed technical information on the Internet!

  • Congratulations SkipVought on being selected by the Tek-Tips community for having the most helpful posts in the forums last week. Way to Go!

SendMessage Error when used with combobox

Status
Not open for further replies.

shavon

Programmer
Jun 18, 2001
102
0
0
CA
Good afternoon:

I am using the following code to auto complete a combo box. However, if I type "I" and beyeon I get an over flow error. The combobox contains over 12000 records coming from a database. Any help would be greatly appreciated. Thank you.



Public Sub SelectItem(cbo As ComboBox, KeyAscii As Integer)
Dim lReturnValue As Long
Dim sFindString As String
Dim gg As Long
If KeyAscii < 32 Or KeyAscii > 127 Then Exit Sub

If cbo.SelLength = 0 Then
sFindString = cbo.Text & Chr$(KeyAscii)
Else
sFindString = Left$(cbo.Text, cbo.SelStart) & Chr$(KeyAscii)
End If

lReturnValue = SendMessage(cbo.hWnd, CB_FINDSTRING, -1, ByVal CStr(sFindString))

'On Error Resume Next
If lReturnValue <> CB_ERR Then
'If lReturnValue <= cbo.ListIndex - 1 Then 21682
gg = lReturnValue

cbo.ListIndex = lReturnValue
cbo.SelStart = Len(sFindString)
cbo.SelLength = Len(cbo.Text) - cbo.SelStart
'End If
End If

KeyAscii = 0
End Sub
 
Status
Not open for further replies.

Part and Inventory Search

Sponsor

Back
Top