forgot the function to search for a string within a string...how do i do that again?
Printable View
forgot the function to search for a string within a string...how do i do that again?
InStr
so i have 2 strings, i want to find choice in StringCompare
If InStr(1, choice, StringComp, vbBinaryCompare) <> True Then
so i'll do that? that will tell me if its not found? :confused:
The Instr() function returns a Long!
And, reverse the Search and String.
So, try:
VB Code:
If InStr(1, StringComp, choice , vbBinaryCompare) <> 0 Then ' Match found
Bruce.
what if i don't know where it starts?:confused:
If you use the 'comparison' argument, you have to include a 'start'.
In that example, it starts at the front end of the string, and will return the first match position.
If you need repeditive search, then return the Instr position and use that next time around as the 'start' position.
(Also see InstrRev (VB6))
Bruce.
never mind, i kind of went nuts with a for loop ;) :p :D thanks guys! im rusty with my vb, its sure been a while! :eek: :D