I have values I loaded into a VB ComboBox. How do I limit the users to only entries on the list. I have code to autofill while typing so I have to keep it as a dropdown combo type so they can actually type into the field. I’d rather not use a 3rd party control. The following is the code I’m using to autofill and am wondering if it can be modified
Public Const CB_FINDSTRING = &H14C
Public Declare Function SendMessage Lib “user32” Alias _
“SendMessageA” (ByVal hwnd As Long, ByVal wMsg As Long, _
ByVal wParam As Long, lParam As Any) As Long
Public Sub AutoFillComboBox(OurBox As ComboBox)
Dim x As Long
Dim StringLen As Long
With OurBox
StringLen = Len(.Text)
If StringLen Then
x = SendMessage(.hwnd, CB_FINDSTRING, -1&, ByVal .Text)
.ListIndex = x
.SelStart = StringLen
.SelLength = Len(.Text) – StringLen
End If
End With
End Sub