|
-
Jul 13th, 2004, 01:15 PM
#1
Thread Starter
New Member
case sensative
i'm currently writing a search program code on vb.net, is there anyway i can make it so that my searchwords are NOT case sensative?
ex: searchword "error" would return results such as "ERROR" "ErRor" "error" "eRRoR" etc.
anyhelp would be greatly appreciated
-
Jul 13th, 2004, 01:32 PM
#2
Hyperactive Member
I would change the case of the string you are searching to match the case of the string you are searching with.
VB Code:
Dim sError As String = "This is an ErrOr"
Dim sSearch As String = "Error"
If sError.ToLower().IndexOf(sSearch.ToLower()) > -1 Then
MessageBox.Show("Found it!")
End If
Whadayamean it doesn't work....
It works fine on my machine!

-
Jul 13th, 2004, 01:35 PM
#3
Thread Starter
New Member
well its a little more complicated than that... see i need to essentially enter random text documents looking for these words so changing the words in the documents i'm searching through probably won't be possible, is there any other alternative? BTW thanks for the suggestion.
-
Jul 13th, 2004, 01:44 PM
#4
Hyperactive Member
it isn't necessary to change the text of the documents. In order to read the documents, you would have to open them into a streamreader anyway, just assign the contents to a variable and then compare the string in the variable with your search value.
If you find it do what you need to do with the rest of the contents of the document.
Whadayamean it doesn't work....
It works fine on my machine!

-
Jul 13th, 2004, 02:00 PM
#5
Thread Starter
New Member
hey... thats not a bad idea... sorry cyberhawk, i misunderstood you the first time. Thanks!
-
Jul 13th, 2004, 03:34 PM
#6
yay gay
Well, use RegularExpressions as they are dead more fast
\m/  \m/
-
Jul 13th, 2004, 03:37 PM
#7
Hyperactive Member
Absolutely, I was going to send a follow-up message once I got home, but you beat me to it.
Whadayamean it doesn't work....
It works fine on my machine!

-
Jul 13th, 2004, 05:14 PM
#8
PowerPoster
Originally posted by PT Exorcist
Well, use RegularExpressions as they are dead more fast
Hi,
He is a new guy and you want him to use REGEX????? That's like putting a 14 year old into an Indy.
Taxes
The more I learn about VB.NET the more I like dBaseIII Plus
The foregoing, whilst believed to be correct, is given without guarantee as to it's accuracy and entirely without recourse. You are required to decide for yourself whether or not it is suitable for your purposes and no liability for loss of any nature can be entertained.
-
Jul 14th, 2004, 05:22 AM
#9
Hyperactive Member
Yeah, but if he makes that first lap...
Whadayamean it doesn't work....
It works fine on my machine!

-
Jul 14th, 2004, 05:51 AM
#10
I wonder how many charact
Well, if you decide not to go with RegEX, use the the Compare method of the String class.
VB Code:
If String.Compare("hi", "Hi", True) = 0 Then Messagebox.Show("Equal")
-
Jul 14th, 2004, 06:00 AM
#11
Hyperactive Member
actually, that was where we started before we started talking about REGEX.
Whadayamean it doesn't work....
It works fine on my machine!

-
Jul 14th, 2004, 06:03 AM
#12
Originally posted by taxes
That's like putting a 14 year old into an Indy.
We already have 14 year olds in the Indies. Same goddamn rednecks winning every time.
-
Jul 14th, 2004, 06:10 AM
#13
PowerPoster
Originally posted by mendhak
We already have 14 year olds in the Indies. Same goddamn rednecks winning every time.
I thought the last Indy Redneck to win was Nigel Mansell.
One up for the UK (BUt only one I'm afraid )
Taxes
The more I learn about VB.NET the more I like dBaseIII Plus
The foregoing, whilst believed to be correct, is given without guarantee as to it's accuracy and entirely without recourse. You are required to decide for yourself whether or not it is suitable for your purposes and no liability for loss of any nature can be entertained.
-
Jul 14th, 2004, 07:39 AM
#14
Frenzied Member
Originally posted by mendhak
We already have 14 year olds in the Indies. Same goddamn rednecks winning every time.
geez, i hate rednecks!!! lol=))
-
Jul 16th, 2004, 01:27 PM
#15
Lively Member
Why all of this ?
VB.Net offers a compilation option: Option Compare, this option controls the behavior of the program when comparing string values, there are 2 options: Option Compare Binary which forces the strings to be in the same case for true equationing, Option Compare Text which compares the text by their characters ignorign the case - and that is the optino you want.
To use option include the statement in the top of the file preceeding any declaration (before the "Imports" statement also).
Examples:
VB Code:
Option Compare Binary
...
Dim Rs As Boolean
If "AaBbCc" = "aabbcc" Then
Rs = True 'Rs is still False
End If
VB Code:
Option Compare Text
...
Dim Rs As Boolean
If "AaBbCc" = "aabbcc" Then
Rs = True 'Rs is True now
End If
Do you think my life is easy?
Do you think it's good to win?
do you think it's nice to kill?
Do you think learning is a must?
Do you think computers are nothing?
Do you think this post is stupid?
Do ypu think we're really humen?
DO YOU THINK IT'S GOOD TO THINK AT ALL? ? ? ! ! !
-
Jul 16th, 2004, 01:31 PM
#16
Hyperactive Member
Originally posted by TLord
Why all of this ?
VB.Net offers a compilation option: Option Compare, this option controls the behavior of the program when comparing string values, there are 2 options: Option Compare Binary which forces the strings to be in the same case for true equationing, Option Compare Text which compares the text by their characters ignorign the case - and that is the optino you want.
To use option include the statement in the top of the file preceeding any declaration (before the "Imports" statement also).
Examples:
VB Code:
Option Compare Binary
...
Dim Rs As Boolean
If "AaBbCc" = "aabbcc" Then
Rs = True 'Rs is still False
End If
VB Code:
Option Compare Text
...
Dim Rs As Boolean
If "AaBbCc" = "aabbcc" Then
Rs = True 'Rs is True now
End If
Option Compare has to do with how your source code compatibility is maintained, not how strings are compared.
If what you are saying were true, then why would Microsoft invest the effort they have into REGEX.
This kind of advice should be thoroughly researched before being offered.
Whadayamean it doesn't work....
It works fine on my machine!

-
Jul 16th, 2004, 01:37 PM
#17
Hyperactive Member
Oops, my bad, I had something else on my mind, TLord is correct, I didn't pay close enough attention to what I was reading.
My appoligies TLord
Whadayamean it doesn't work....
It works fine on my machine!

-
Jul 16th, 2004, 01:45 PM
#18
Lively Member
Do you think my life is easy?
Do you think it's good to win?
do you think it's nice to kill?
Do you think learning is a must?
Do you think computers are nothing?
Do you think this post is stupid?
Do ypu think we're really humen?
DO YOU THINK IT'S GOOD TO THINK AT ALL? ? ? ! ! !
-
Jul 16th, 2004, 04:26 PM
#19
PowerPoster
Originally posted by CyberHawke
Oops, my bad, I had something else on my mind, TLord is correct, I didn't pay close enough attention to what I was reading.
My appoligies TLord
Yes, you must not try to put too much into such a tiny space
Taxes
The more I learn about VB.NET the more I like dBaseIII Plus
The foregoing, whilst believed to be correct, is given without guarantee as to it's accuracy and entirely without recourse. You are required to decide for yourself whether or not it is suitable for your purposes and no liability for loss of any nature can be entertained.
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
|