Here's my test:
Start a new project and put a command button on the form. Then put this code in the Click event of the command button:
As far as I know, there are no errors in that test code. It shows InStr to be consistently faster than Like.Code:Dim ISt As Single, IE As Single Dim LSt As Single, LE As Single Dim B As Boolean Dim I As Long Const Times = 1000000 Dim TestStr As String TestStr = "hi!" Me.AutoRedraw = True Me.FontName = "Fixedsys" ISt = Timer For I = 1 To Times B = InStr(TestStr, "!") > 0 Next I IE = Timer LSt = Timer For I = 1 To Times B = TestStr Like "*!*" Next I LE = Timer Cls Print "InStr: "; vbTab; IE - ISt Print "Like: "; vbTab; LE - LSt




Reply With Quote