-
I am just wondering this because i use code similar to this pretty often. I wonder if there is a faster way to do this. Usually this is okay, but sometimes, instead of a text box, it loops thru 1000 or more strings in a variable array, and is a bit slow.
------------------------------------------------------
Command1_Click
intLength = Len(Text2.Text)
intLength2 = Len(Text1.Text)
If intLength > intLength2 Then Exit Sub
intDifference = intLength2 - intLength
For intNumTimes = 0 To intDifference
strPart = Mid(Text1.Text, intNumTimes + 1, intLength2)
If strPart = Text2.Text Then
MsgBox("String Found")
Exit Sub
End If
Next intLoop
MsgBox("String Not Found")
End Sub
--------------------------------------------------------
Any thoughts?
-
oh, in case it isn't obvious, the user types text in textbox 2 and clicks command 1.
Then the app. looks for a match of the text in textbox 2 in textbox1.
-
I think that this would be faster...
Command1_Click
if instr(Text1.Text, Text2.Text) > 0 then
MsgBox ("String Found")
else
MsgBox ("String Not Found")
end if
End Sub
-
That is exactly the little diddy i was driving at. I knew it existed.
Well, I have a lot of programs to update now, so catcha later.
btw, thanks.