|
-
May 3rd, 2008, 02:43 PM
#1
Thread Starter
Frenzied Member
[RESOLVED] Ignoring Case in String Comparison
It's been a long time since I've done any coding, and I feel like an idiot for having to ask this and not being able to just figure it out but I'm being kind of lazy and I promised work that I'd have this report run for them. Is there a simple way to ignore case in a string, or is there a simple way to convert a string to all lowercase? The method I've thought of is splitting the string into a variant, going through the variant and figuring out of the ASCII code for each letter was cap or lowercase, making it all lowercase, and then re-assembling the string but this will add significant time to the time it will take me to run this report as I'm comparing a list of about 300 names to a list of about 6000 names and would need to do this for each one in addition to some other code that ultimately writes several values for each name on a spreadsheet.
Any help would be appreciated
Last edited by Skitchen8; May 4th, 2008 at 09:15 AM.
Government is another way to say better…than…you.
It’s like ice but no pick, a murder charge that won’t stick,
it’s like a whole other world where you can smell the food,
but you can’t touch the silverware.
Huh, what luck. Fascism you can vote for.
Humph, isn’t that sweet?
And we’re all gonna die some day, because that’s the American way
-Stone Sour
-
May 3rd, 2008, 03:22 PM
#2
Re: Ignoring Case in String Comparison
You can use LCase$() or UCase$() to convert a String to lower/upper case. Also, you can use 'Option Compare Text' in Module's Declaration level. E.g.:
Code:
Option Explicit
Option Compare Text 'ignores case
Private Sub Form_Load()
Dim x As String
Dim y As String
x = "Visual Basic"
y = "visual basic"
Debug.Print LCase$(x) = y
Debug.Print x = y 'only returns True if 'Option Compare Text' is used
End Sub
-
May 3rd, 2008, 04:47 PM
#3
Re: Ignoring Case in String Comparison
Another way
Code:
If StrComp(x, y, vbTextCompare) = 0 Then
MsgBox "equal"
End If
-
May 3rd, 2008, 06:02 PM
#4
Re: Ignoring Case in String Comparison
The best way:
At the top of your form/module/class if you are not doing any binary compares...
Last edited by randem; May 3rd, 2008 at 06:05 PM.
-
May 4th, 2008, 09:15 AM
#5
Thread Starter
Frenzied Member
Re: Ignoring Case in String Comparison
Thanks a lot guys, the help is greatly appreciated
Government is another way to say better…than…you.
It’s like ice but no pick, a murder charge that won’t stick,
it’s like a whole other world where you can smell the food,
but you can’t touch the silverware.
Huh, what luck. Fascism you can vote for.
Humph, isn’t that sweet?
And we’re all gonna die some day, because that’s the American way
-Stone Sour
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
|