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

Search based on Input, results display in list box..

Status
Not open for further replies.

jmlady

Programmer
Nov 20, 2003
19
0
0
US
Hey, I have a code that takes a user input from Text1.Text and searches a dictionary.txt file for all words containing character values. My problem is, however, if I put in the letters "BORDER", in the return List1 box, I I don't want results that have two "E"'s, three "O"'s, etc. I just want the return result to contain all of the characters, or use those EXACT input characters to list all other words, like "RODE". THis is the code that i"m currently using..

Private Sub cmdFind_Click()
'******
'Find Matches
'******
myStr = Text1.Text
Dim i As Integer
Dim j As Integer
Dim KeepGoing As Boolean
For i = 0 To UBound(searchArray())
j = 1: KeepGoing = True
While j <= Len(myStr) And KeepGoing
If InStr(1, myStr, Mid$(searchArray(i), j, 1)) = 0 Then KeepGoing = False
j = j + 1
Wend
If KeepGoing Then List1.AddItem searchArray(i)
Next i
End Sub

Any help, again, would be greatly appreciated
Thanks
 
Sort the letters within the dictionary words into alphabetical order, then do the same with your search string. That way you should only get matches when words have the same letters.

Andy
&quot;Logic is invincible because in order to combat logic it is necessary to use logic.&quot; -- Pierre Boutroux
&quot;A computer program does what you tell it to do, not what you want it to do.&quot; -- Greer's Third Law
 
That won't work...say I search for something like &quot;allure&quot;
- aellru

if I have a word like &quot;lee&quot; or something, it will keep bringing repeating letters...which is what i can't figure out.
 
Use the Mid() statement (not function) to remove the matched letters before going on to next letter

________________________________________________________________
If you want to get the best response to a question, please check out FAQ222-2244 first

'People who live in windowed environments shouldn't cast pointers.'
 
why don't you look at writing a sub that returns the input word, with all the lettes in alpha order.

eg: allure ---> aellur

then iterate through the .txt file, and everytime you get to a word, use the same function to order the letters in the stored word.

If these two strings are equal then add the word in the dictionary to the listbox.

If you need any help, just post.

BB
 
Status
Not open for further replies.

Part and Inventory Search

Sponsor

Back
Top