|
-
Jul 23rd, 2003, 01:51 AM
#1
Thread Starter
Hyperactive Member
Search a String
Ok lets say I have a string composed of this text (including the quotes)
Hello "bob how are" you?
what would be the fastest way to search that string to see if it contains a " (quote marks)? I know i could use the mid instruction and put it in the middle of a loop and just check every char one at a time, but that is slow. I cant split the string because i want to keep the " not use it as the dilimiter. Does vb.net have a search function like c++? Because i have a feeling vb would have a built in function that is faster then anything i can write.
-
Jul 23rd, 2003, 02:10 AM
#2
you could use InStr to check if the " is there.
~
if a post is resolved, please mark it as [Resolved]
protected string get_Signature(){return Censored;}
[vbcode][php] please use code tags when posting any code [/php][/vbcode]
-
Jul 23rd, 2003, 02:11 AM
#3
The String object has an IndexOf method that returns the index of the first instance of the search string or -1 if non is found.
VB Code:
Dim test As String="Hello ""bob how are"" you?"
If test.IndexOf(ControlChars.Quote)=-1 Then Msgbox("Not Found")
I'm getting slow in my old age...
Last edited by Edneeis; Jul 23rd, 2003 at 02:14 AM.
-
Jul 23rd, 2003, 02:12 AM
#4
Thread Starter
Hyperactive Member
so i am guessing that is like the strcmp function in c++? It just returns a boolean true if it is there, or false if it is not there?
-
Jul 23rd, 2003, 02:13 AM
#5
Thread Starter
Hyperactive Member
I think that may of solved my problem, now to attempt to write some fast code, thank you for your time and help.
-
Jul 23rd, 2003, 04:53 AM
#6
Fanatic Member
the indexOf-function doesn't return True or False like your c++Function does. This fucntion returns the index of the string you're looking for int the base-string. When it returns -1, this means that the string is not found.
I wouldn'd adise to still use the instr-function. This is a VB6-function that is still suported, but it's better to use the .NET-function .IndexOf.
- Use the thread tools to Mark your Thread as Resolved when your question is answered.
- Please Rate my answers if they where helpful.
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
|