Would you mind telling me how to find out if the string i type in the textbox contains the word "name" or not?
Printable View
Would you mind telling me how to find out if the string i type in the textbox contains the word "name" or not?
This really doesn't need to be in the API section, because InStr() (and what you are asking) isn't related to API.
VB Code:
If (InStr(1, string, "name", vbBinarCompare) > 0) Then 'its there End If
Phreak
Just a typo I guess but it's vbBinaryCompare ;)Quote:
Originally posted by «°°phReAk°°»
This really doesn't need to be in the API section, because InStr() (and what you are asking) isn't related to API.
VB Code:
If (InStr(1, string, "name", vbBinarCompare) > 0) Then 'its there End If
Phreak
It can be used like Phreak and Manavo11 said:
VB Code:
If (InStr(1, string, "name", vbBinaryCompare) > 0) Then 'its there End If
But it can be used also like this:
VB Code:
Dim FindString as integer FindString = Instr (1 , string, "name") Do While FindString > 0 'Do something when is > 0 FindString = Instr (1 , string, "name") Loop
I know that i am saying the same as Phreak and Manavo11 said but in my opinion it is better using Do...Loop and not If...Else..End If!
Sorry guys!
Also can i make a question?
"Why to use this:InStr(1,string , "name" , vbBinaryCompare) and not this: InStr (1, string, "name"), isn't the same thing?
vbBinaryCompare and vbTextCompare
If you use InStr() to search for, "name", it will also find:
"name" "NAME" "nAME" "NaMe"...
But if you use vbBinaryCompare, it will find the EXACT string:
VB Code:
InStr(1, "Enter name:", "name", vbBinaryCompare)
That will only find "name", and not "NAME" "NaMe" or any other combination.
PS: Im not at home atm, so thats why im not on MSN :p
Phreak
Ok! Thanks Phreak!
See u on MSN , when u will return!