Login | Register   
LinkedIn
Google+
Twitter
RSS Feed
Download our iPhone app
TODAY'S HEADLINES  |   ARTICLE ARCHIVE  |   FORUMS  |   TIP BANK
Browse DevX
Sign up for e-mail newsletters from DevX


Tip of the Day
Language: Visual Basic
Expertise: Beginner
Mar 26, 1999

Perform Look-Ahead Typing

This subroutine lets the user perform look-ahead typing, as in Netscape Navigator, Microsoft Internet Explorer, and other apps. The sub takes an array of strings and a TextBox control as parameters. You can easily change the subroutine to accept a ListBox control instead of an array of strings. You can call this sub from the TextBox's KeyUp event:
 
Public Sub DoLookAhead(strArray() As String, ctlText _
	As TextBox)
	Dim strText As String
	Dim strLength As Integer
	Dim x As Integer

	strText = LCase$(ctlText.Text)
	strLength = Len(strText)

	If strLength > 0 Then
		For x = LBound(strArray) To UBound(strArray)
		If strText = LCase$(Left$(strArray(x), strLength)) _
			Then
			'we found something
			If Len(strArray(x)) > strLength Then
				ctlText.Text = ctlText.Text + _
					Mid$(strArray(x), strLength + 1)
				ctlText.SelStart = strLength
				ctlText.SelLength = Len(strArray(x)) - _
					strLength
			End If
			Exit For
		End If
		Next
	End If
End Sub
Robert Gelb
 
Comment and Contribute

 

 

 

 

 


(Maximum characters: 1200). You have 1200 characters left.

 

 

Sitemap
Thanks for your registration, follow us on our social networks to keep up-to-date