Best/Easiest way to search/find in a string
Hi Joel,
'-----------------
You have to consider if the CASE makes a difference in you text. You may
want to force all text to uppercase before you do a comparison. Instr is
case sensitive, while using "=" is not case sensitive.
'-----------------
Try:
'=============
Public Sub Tester()
Dim iPos As Long
Dim jPos As Long
Const sStr As String = "A CAT AND A DOG"
Const sStr2 As String = "cat"
iPos = InStr(1, sStr, sStr2, vbTextCompare)
jPos = InStr(1, sStr, sStr2, vbBinaryCompare)
MsgBox Prompt:="vbTextCompa " & iPos _
& vbNewLine _
& "vbBinaryCompare : " & jPos
End Sub
'<<=============
---
Regards,
Norman
|