cyberbiker
Programmer
I found some code on one of the tek-tip forums quite a long time ago and saaved it for future use.
But it develops an error when I tried to use it on this line:
nRet& = SendMessage(Combo1.hWnd, WM_SETREDRAW, False, 0&)
The error: Can't find dll entry point Send Message in user32.
I think that I might have corrupt user32.dll, but that is just a guess. Can anybody help me out.
The code I copied from the forum is to autocomplete the entry into a combo box and is as follows:
'Add a module to your project (In the menu choose Project -> Add Module, Then click Open)
'Add 1 Combo Box to your form. Set the Combo Box Style property to 2 - DropDown List.
'Add few items to the Combo Box list, some of them should begin with the same character.
'When you will press a key, the first item that begins with the key you pressed will be selected.
'If you will press the same key again, the second item that begins with the key you pressed
'will be selected.
'Insert the following code to the module :
Public strCombo As String
Public Const WM_SETREDRAW = &HB
Public Const KEY_A = 65
Public Const KEY_Z = 90
Declare Function SendMessage Lib "User32" (ByVal hWnd As Integer, ByVal wMsg As _
Integer, ByVal wParam As Integer, lParam As Any) As Long
'Insert the following code to your form:
Private Sub Combo1_KeyDown(KeyCode As Integer, Shift As Integer)
Dim x%
Dim strTemp$
Dim nRet&
If KeyCode >= KEY_A And KeyCode <= KEY_Z Then
'only look at letters A-Z
strTemp = Combo1.Text
If Len(strTemp) = 1 Then strCombo = strTemp
nRet& = SendMessage(Combo1.hWnd, WM_SETREDRAW, False, 0&)
For x = 0 To (Combo1.ListCount - 1)
If UCase((strTemp & Mid$(Combo1.List(x), Len(strTemp) + 1))) = UCase(Combo1.List(x)) Then
Combo1.ListIndex = x
Combo1.Text = Combo1.List(x)
Combo1.SelStart = Len(strTemp)
Combo1.SelLength = Len(Combo1.Text) - (Len(strTemp))
strCombo = strCombo & Mid$(strTemp, Len(strCombo) + 1)
Exit For
Else
If InStr(UCase(strTemp), UCase(strCombo)) Then
strCombo = strCombo & Mid$(strTemp, Len(strCombo) + 1)
Combo1.Text = strCombo
Combo1.SelStart = Len(Combo1.Text)
Else
strCombo = strTemp
End If
End If
Next
nRet& = SendMessage(Combo1.hWnd, WM_SETREDRAW, True, 0&)
End If
End Sub
Terry (cyberbiker)
But it develops an error when I tried to use it on this line:
nRet& = SendMessage(Combo1.hWnd, WM_SETREDRAW, False, 0&)
The error: Can't find dll entry point Send Message in user32.
I think that I might have corrupt user32.dll, but that is just a guess. Can anybody help me out.
The code I copied from the forum is to autocomplete the entry into a combo box and is as follows:
'Add a module to your project (In the menu choose Project -> Add Module, Then click Open)
'Add 1 Combo Box to your form. Set the Combo Box Style property to 2 - DropDown List.
'Add few items to the Combo Box list, some of them should begin with the same character.
'When you will press a key, the first item that begins with the key you pressed will be selected.
'If you will press the same key again, the second item that begins with the key you pressed
'will be selected.
'Insert the following code to the module :
Public strCombo As String
Public Const WM_SETREDRAW = &HB
Public Const KEY_A = 65
Public Const KEY_Z = 90
Declare Function SendMessage Lib "User32" (ByVal hWnd As Integer, ByVal wMsg As _
Integer, ByVal wParam As Integer, lParam As Any) As Long
'Insert the following code to your form:
Private Sub Combo1_KeyDown(KeyCode As Integer, Shift As Integer)
Dim x%
Dim strTemp$
Dim nRet&
If KeyCode >= KEY_A And KeyCode <= KEY_Z Then
'only look at letters A-Z
strTemp = Combo1.Text
If Len(strTemp) = 1 Then strCombo = strTemp
nRet& = SendMessage(Combo1.hWnd, WM_SETREDRAW, False, 0&)
For x = 0 To (Combo1.ListCount - 1)
If UCase((strTemp & Mid$(Combo1.List(x), Len(strTemp) + 1))) = UCase(Combo1.List(x)) Then
Combo1.ListIndex = x
Combo1.Text = Combo1.List(x)
Combo1.SelStart = Len(strTemp)
Combo1.SelLength = Len(Combo1.Text) - (Len(strTemp))
strCombo = strCombo & Mid$(strTemp, Len(strCombo) + 1)
Exit For
Else
If InStr(UCase(strTemp), UCase(strCombo)) Then
strCombo = strCombo & Mid$(strTemp, Len(strCombo) + 1)
Combo1.Text = strCombo
Combo1.SelStart = Len(Combo1.Text)
Else
strCombo = strTemp
End If
End If
Next
nRet& = SendMessage(Combo1.hWnd, WM_SETREDRAW, True, 0&)
End If
End Sub
Terry (cyberbiker)