Suppose s1 = "S02K"
s2 = "S02KKKK"
How to check that these 2 strings are similar ?
I have used "like" to check them, but it won't work !!!
Printable View
Suppose s1 = "S02K"
s2 = "S02KKKK"
How to check that these 2 strings are similar ?
I have used "like" to check them, but it won't work !!!
Dim Pos As Integer
Pos = InStr(1,s2,s1)
If s1 is found in s2 then Pos will equal something other than 0. If s1 is not found in s2 then Pos will return 0.
PGregoire's solution will only let you know if s1 is a part of s2. If you want to compare that 2 strings are alike
If StrComp(s1, s2, vbTextCompare) = 0 Then
Call MsgBox("strings are the same")
Else
Call MsgBox("strings are different")
End If
Iouri Boutchkine
[email protected]
A perfectly correct answer, although a little C influenced. When we are using VB we could simply check:
If s1 = s2 then
MsgBox "Strings are the same"
else
MsgBox "Strings are different"
End If
-----------------------
Daniel Andersson