LinkBack Thread Tools Search this Thread Display Modes
Prev Previous Post   Next Post Next
  #14   Report Post  
Posted to microsoft.public.excel.programming
external usenet poster
 
Posts: 27,285
Default Performance Difference - LCase vs UCase?

b was a variant since strcomp returns a long and the others were returning a
boolean. didn't want to introduce implied coercian.

--
Regards,
Tom Ogilvy


"GKeramidas" wrote in message
...
'option compare text
7.998047
8.172852
1.112793
4.482422

option compare text
11.10986
11.33398
9.054932
4.460938

--


Gary

--


Gary


"GKeramidas" wrote in message
...
meant to ask what it should be dimmed as

anyway
here are my results

11.10986
11.33398
9.054932
4.460938

--


Gary


"GKeramidas" wrote in message
...
tom:

what is b

b = (UCase(s1) = UCase(s2))

--


Gary


"Tom Ogilvy" wrote in message
...
I got Like as being slower then Ucase and Lcase which seemed to be the
same, but strcomp was considerably faster.

test was:
LCase
Ucase
Like
StrComp


7.984985
7.984009
8.609985
3.406006

that was with Option Compare Text turned on all the time.

If I turned it off, then Like was extremely fast (it could reject on
the first character of each string). But it would to a case sensitive
compare and give the wrong answer.

6.703003
6.703003
1.015015
3.406982

'Option Compare Text

Sub ABC()
Dim sngStart As Single, sngEnd As Single
Dim i As Long, s1 As String, s2 As String
Dim cnt As Long
cnt = 10000000
s1 = "ABCdef"
s2 = "abcDEg"
sngStart = Timer
For i = 1 To cnt
b = (UCase(s1) = UCase(s2))
Next
Debug.Print Timer - sngStart

sngStart = Timer
For i = 1 To cnt
b = (LCase(s1) = LCase(s2))
Next
Debug.Print Timer - sngStart

sngStart = Timer
For i = 1 To cnt
b = s1 Like s2
Next
Debug.Print Timer - sngStart



sngStart = Timer
For i = 1 To cnt
b = StrComp(s1, s2, vbTextCompare)
Next
Debug.Print Timer - sngStart

End Sub

--
Regards,
Tom Ogilvy


"NickHK" wrote in message
...
You also have the StrComp() function
Or go back to basics with
Declare Function lstrcmpi Lib "kernel32" Alias "lstrcmpiA" (ByVal
lpString1
As String, ByVal lpString2 As String) As Long

Can't say is fastest, but I would assume the API version.

NickHK

"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!









 
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 07:20 PM.

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"