Home |
Search |
Today's Posts |
#14
![]()
Posted to microsoft.public.excel.programming
|
|||
|
|||
![]()
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 |
Display Modes | |
|
|
![]() |
||||
Thread | Forum | |||
Can I get VBA script to read a word with both lcase and ucase lett | Excel Programming | |||
UCase? | Excel Programming | |||
Get…UCase or LCase ??? | Excel Programming | |||
Get…UCase or LCase ??? | Excel Programming | |||
UCase Help | Excel Programming |