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 Chriss Miller on being selected by the Tek-Tips community for having the most helpful posts in the forums last week. Way to Go!

"link" a text box to a list box 1

Status
Not open for further replies.

MazeWorX

IS-IT--Management
Nov 17, 2002
762
CA
does anyone have any info on: "link" a text box to a list box so the nearest match in the list box is selected when the user types text into the text box Remember amateurs built the ark - professionals built the Titanic

[yoda]
 
Hi there,

you need to put some VBA code in the key down or key up event of your textbox. The code will simply take what has been typed and loop through each item in the listbox to see if there is a match or likeness.

Private Sub Text0_KeyUp(KeyCode As Integer, Shift As Integer)

Dim strText As String
Dim i As Integer

strText = Text0.Text

For i = 0 To List4.ListCount
If strText = List4.ItemData(i) Then
List4.Selected(i) = True
End If
Next

End Sub
Hope this helps!

Transcend
[noevil]
 
Hi again,

sorry this line

For i = 0 To List4.ListCount

should be

For i = 0 To List4.ListCount - 1

Transcend
[noevil]
 
works perfect on the Key up event

Many Thanks ... nice simple solution

Remember amateurs built the ark - professionals built the Titanic

[flush]
 
no prob got it already (-:
Remember amateurs built the ark - professionals built the Titanic

[flush]
 
Spoke to soon :-( What if I want to introduce '*' into the comparison so as the user enters text the selected field moves with them, as opposed to the way it is now the user must match the whole string for the desired affect Remember amateurs built the ark - professionals built the Titanic

[flush]
 
Never mind got it


If List0.ItemData(i) Like strText & "*" Then Remember amateurs built the ark - professionals built the Titanic

[flush]
 
Status
Not open for further replies.

Part and Inventory Search

Sponsor

Back
Top