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

Creating an Alpha Search....

Status
Not open for further replies.

PogoWolf

Programmer
Mar 2, 2001
351
0
0
US
well, I'm needing a little help how to implement this function into a program. I have a Array that holds all the needed data. a text box that holds the 'query' on a keypress I would like the program to search though the array and report back the matches to the query.

SO like if a user presses 'a' it will return all the items in the array that begin with 'a' .. and if the user presses
'b' next, it will return all the 'ab'.. and then if they press backspace it'll return all the 'a' again.

I do have some code that doesn't seem to filter the data at all.. my Email is pogowolf@hotmail, for I relaize this is not a 'small' task.. =)
(well, at least I don't think it is.. LOL)
---===///The PogoWolf\\\===---
Darkness..Bleakness..Plastic forks..?

 
Update:
OK, I Was able to figure out how to do this..
but I"m getting a 'weird' issue. When you press a key it does the search.. but doesn't refresh the screen!?

it does the search correctly.. but I need it to update as soon as the user types something in...



here's the code:
Dim X As Integer '//Used as a Counter
Dim Pointer As Integer '//Used as the string 'Pointer'
Dim Result As Integer '//Good/Bad Search?
Dim Query As String '//The Query

Pointer = Len(Me.TXT_Query)
Query = UCase(Me.TXT_Query.Text)
Me.Lst_Main.Clear
Me.TXT_Query.SetFocus
For X = 0 To UBound(DataArray())
Result = InStr(UCase(Left(DataArray(X), Pointer)), Query)
If Result > 0 Then
Me.Lst_Main.AddItem DataArray(X)
End If
Next

Me.SetFocus
Me.Refresh ---===///The PogoWolf\\\===---
Darkness..Bleakness..Plastic forks..?

 
you might try to use the "change" event instead of the "keypress". if you press backspace, change and keydown will be fired while i'm almost sure keypress will not.
 
Status
Not open for further replies.

Part and Inventory Search

Sponsor

Back
Top