FWIW, InstrB is significantly faster than the RTLCompare-function:
(especially when used in "String-Mode", to avoid the conversions)
OlafCode:Private Sub Form_Click() Cls Dim i As Long, T As Single T = Timer Dim bHay() As Byte, bNeedle() As Byte bHay = StrConv("asdfasdfasdf_1234_qwerqwerqwer", vbFromUnicode) bNeedle = StrConv("1234", vbFromUnicode) For i = 1 To 10 ^ 6 If ByteComp(bHay, bNeedle) <> 13 Then Stop Next Print "ByteComp: ", CLng((Timer - T) * 1000) & "msec" T = Timer Dim sHay As String, sNeedle As String sHay = StrConv("asdfasdfasdf_1234_qwerqwerqwer", vbFromUnicode) sNeedle = StrConv("1234", vbFromUnicode) For i = 1 To 10 ^ 6 If InStrB(sHay, sNeedle) <> 14 Then Stop Next Print "InStrB: ", CLng((Timer - T) * 1000) & "msec" End Sub




Reply With Quote