Reply
 
LinkBack Thread Tools Search this Thread Display Modes
  #1   Report Post  
Posted to microsoft.public.excel.programming
external usenet poster
 
Posts: 2,494
Default Performance Difference - LCase vs UCase?

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!



  #2   Report Post  
Posted to microsoft.public.excel.programming
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!



  #3   Report Post  
Posted to microsoft.public.excel.programming
external usenet poster
 
Posts: 38
Default Performance Difference - LCase vs UCase?

ok, got it thanks.

it eliminates the need to make the case the same to find a match.

--


Gary


"Jim Cone" wrote in message
...
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!




Reply
Thread Tools Search this Thread
Search this Thread:

Advanced Search
Display Modes

Posting Rules

Smilies are On
[IMG] code is On
HTML code is Off
Trackbacks are On
Pingbacks are On
Refbacks are On


Similar Threads
Thread Thread Starter Forum Replies Last Post
Can I get VBA script to read a word with both lcase and ucase lett Calle Excel Programming 8 July 7th 06 04:20 PM
UCase? vbastarter Excel Programming 4 March 13th 06 01:00 AM
Get…UCase or LCase ??? Totmos Excel Programming 0 January 8th 04 07:09 PM
Get…UCase or LCase ??? Totmos Excel Programming 2 January 8th 04 06:15 PM
UCase Help holder2k[_2_] Excel Programming 2 November 22nd 03 03:35 PM


All times are GMT +1. The time now is 10:03 AM.

Powered by vBulletin® Copyright ©2000 - 2025, Jelsoft Enterprises Ltd.
Copyright ©2004-2025 ExcelBanter.
The comments are property of their posters.
 

About Us

"It's about Microsoft Excel"