Click to See Complete Forum and Search --> : vb auto fill text
how can i get the functionality in text box of auto fill, just like happen in Internet Explorer address bar,
i want to fill the text automatically with the company name, as soon as i write the first letter of that company,
means just the same functionality as we see in the msdn search,
plz help
thanks
sanon
Sep 16th, 2000, 05:27 PM
Basically, you have to keep information in some sort of database, such as text file or access, and then when you type in the textbox, you have to write a sub that search through that database.
Edneeis
Sep 16th, 2000, 09:14 PM
This kinda works if you store the list data to fill in an array.
CommonCity would be a string array with the data and CityLetters is how many letters into the word do you want to intiate the search.
Private Sub Text3_KeyUp(KeyCode As Integer, Shift As Integer)
If KeyCode <> 8 Then
For X = 0 To 4
If LCase(Text3.Text) = LCase(Left(CommonCity$(X), CityLetters%)) Then
Text3.Text = CommonCity$(X)
Text3.SelStart = CityLetters%
SendKeys "+{End}"
End If
Next X
End If
End Sub
ALthough if you can put the info in a database then it becomes a lot easier.
Here is the same situation but with a database (it works better)
deTracker is a data environment and rstbCmns is a recordset you should be able to figure the rest out.
Private Sub txtCity_KeyUp(KeyCode As Integer, Shift As Integer)
If KeyCode <> 8 And Len(txtCity.Text) > 1 And Shift = 0 Then
pWord = txtCity.Text
On Error GoTo nomatch
deTracker.rstbCmns.Filter = "City Like '" & pWord & "*'"
deTracker.rstbCmns.MoveFirst
txtCity.Text = txtCity.Text & Mid(deTracker.rstbCmns!City, Len(pWord) + 1, Len(deTracker.rstbCmns!City))
txtCity.SelStart = Len(pWord)
txtCity.SelLength = Len(txtCity.Text) - Len(pWord)
nomatch:
ElseIf Shift = 1 Then
txtCity.SelStart = Len(pWord)
txtCity.SelLength = Len(txtCity.Text) - Len(pWord)
End If
End Sub
vbforums.com
Copyright Internet.com Inc., All Rights Reserved.