Breaking down strings to search on

Lol Owen

Registered User.
Local time
Today, 04:32
Joined
Mar 15, 2004
Messages
86
Hi all, got a curious one. Suppose I have a text box on a form. In that text box I type words which I want to use to perform a search with. The words would be de-limited by say ";" eg>

Car;Bus;Bike

I need to examine the contents of the text box a character at a time until I find the semi-colon. The characters preceeding the semi-colon are assigned to a string variable. Once a space is encountered that means the end of the string and shouyld initiate the search. I appreciate that for the first string the characters preceeding the semi colon will be assigned to a string and subsequent characters occuring after the semi-colon will be assigned toa string.

Anyone have any ideas please :D

Cheers, Lol :D
 
Dim ind as Integer

For i = 1 to len(myString)
ReDim a(i)
if mid(myString,i,1) <> ";" Then
a(ind) = a(ind) & mid(myString,i,1)
else
ind = ind + 1
end if
Next i

This loads all of the strings into an array.
 
If you don't know how many strings then use a dynamic array.

You can easily loop through the string and look for the semicolon or there is a cool function that looks for a pattern as well.
 
I guess I typed the previous post while tkpstock was actually typing the code to what I was referring :)

So Lol, we both agree on the same answer.


though, whenever you know you are comparing strings or returning them use the actual string function mid$() instead of mid(). This saves processor time in converting a variant to a string.
 
Last edited:
Thanks folks, actually used the split function and it works well so far!

Cheers, Lol
 

Users who are viewing this thread

Back
Top Bottom