View Single Post
  #5   Report Post  
Posted to microsoft.public.excel.programming
Jim Cone Jim Cone is offline
external usenet poster
 
Posts: 3,290
Default Performance Difference - LCase vs UCase?

Gary,
Option Compare Text makes all text comparisons case insensitive.
Regards,
Jim Cone
San Francisco, USA
http://www.officeletter.com/blink/specialsort.html


"Gary Keramidas"
<GKeramidasATmsn.com
wrote in message
jim i have a question on this and the option compare text

if i run the following code with option compare text under option explicit, i
get "the same"
if i remove option compare text, i get "different"

why the difference?

Sub test()
str1 = "Gary"
str2 = "gary"

If str1 Like str2 Then
MsgBox "the same"
Else
MsgBox "different"
End If
End Sub


--


Gary


"Jim Cone" wrote in message
...
If I were doing it I would use the "Like" operator...
If string1 Like string2 Then
This requires the "Option Compare Text" statement at the top of the module.

I doubt if there is any difference in the time required for Ucase vs. Lcase.
If time is an issue, then run each code version and time it..
--
Jim Cone
San Francisco, USA
http://www.realezsites.com/bus/primitivesoftware


"MDW"
wrote in message
Hello,
I'm going to be comparing a bunch of string variables in a case-insensitive
scenario. I will be using the tried and true method of "If LCase(string1) =
LCase(string2) Then..."
However, I'm going to be doing this thousands of times. It's irrelevant to
me if I compare the strings in upper case or lower. Is it any more "work" for
VBA to convert a string to all uppers vs all lowers (or vice versa)? Is
~5,000 conversions enough for any difference (if there is one) to impact
performance?
Thanks.
--
Hmm...they have the Internet on COMPUTERS now!