|
-
Feb 15th, 2000, 10:24 PM
#1
Thread Starter
New Member
I want to type in the first letter of a word and the rest of the word must appear automatically as I type it in the list box or combo box(Like when you try to enter a URL and it appears automatically and choose it from the list of options given).Please help.
-
Feb 15th, 2000, 11:42 PM
#2
Frenzied Member
There's probably a better way but I just knocked this up for you...
Code:
Option Explicit
Dim strInput As String
Private Sub Combo1_Change()
Dim i As Integer
Dim match As Boolean
match = False
If strInput <> "" Then
For i = 0 To Combo1.ListCount - 1
If Left(Combo1.List(i), Len(strInput)) = strInput Then
Combo1.ListIndex = i
match = True
End If
Next
End If
If Not match Then
Combo1.Text = strInput
End If
Combo1.SelStart = Len(strInput)
Combo1.SelLength = Len(Combo1.Text) - Len(strInput)
End Sub
Private Sub Combo1_KeyPress(KeyAscii As Integer)
On Error Resume Next
If KeyAscii >= 32 And KeyAscii <= 126 Then
strInput = strInput & Chr(KeyAscii)
End If
If KeyAscii = 8 Then
strInput = Left(strInput, Len(strInput) - 1)
End If
End Sub
Private Sub Form_Load()
Combo1.AddItem "aaaaa"
Combo1.AddItem "bbbcceeedd"
Combo1.AddItem "bbbaa"
End Sub
------------------
Mark Sreeves
Analyst Programmer
[email protected]
A BMW Group Company
-
Feb 15th, 2000, 11:46 PM
#3
You can try to use the SendMessage api.
Declare Function SendMessage Lib "User32" Alias "SendMessageA" (ByVal 1hWnd As Long, ByVal wMsg As Long, ByVal wParam As Long, lParam As String) As Long
Const LB_FINDSTRING = &H18F
Private Sub Text_Change()
List.ListIndex = SendMessage(List.hWnd, LB_FINDSTRING, -1, ByVal Text.Text)
End Sub
-Kayoca Mortation 
-
Feb 16th, 2000, 12:15 PM
#4
Addicted Member
For combo control, set style to dropdown list, it will do what you want, I didn't try listbox, it may work too! Goodluck!
Posting Permissions
- You may not post new threads
- You may not post replies
- You may not post attachments
- You may not edit your posts
-
Forum Rules
|
Click Here to Expand Forum to Full Width
|