-
Apr 4th, 2004, 09:37 AM
#1
Thread Starter
Addicted Member
please tell me how to use Instr() function?
Would you mind telling me how to find out if the string i type in the textbox contains the word "name" or not?
-
Apr 4th, 2004, 12:48 PM
#2
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
Visual Studio 6, Visual Studio.NET 2005, MASM
-
Apr 5th, 2004, 05:00 PM
#3
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
Just a typo I guess but it's vbBinaryCompare
Has someone helped you? Then you can Rate their helpful post.
-
Apr 9th, 2004, 05:27 AM
#4
Hyperactive Member
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?
-
Apr 9th, 2004, 05:32 AM
#5
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
Phreak
Visual Studio 6, Visual Studio.NET 2005, MASM
-
Apr 9th, 2004, 05:47 AM
#6
Hyperactive Member
Ok! Thanks Phreak!
See u on MSN , when u will return!
Posting Permissions
- You may not post new threads
- You may not post replies
- You may not post attachments
- You may not edit your posts
-
Forum Rules
|
Click Here to Expand Forum to Full Width
|