|
-
March 28th, 2001, 10:24 PM
#1
How to compare 2 similar strings?
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 !!!
-
March 28th, 2001, 11:20 PM
#2
Re: How to compare 2 similar strings?
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.
-
March 29th, 2001, 08:26 AM
#3
Re: How to compare 2 similar strings?
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]
-
March 30th, 2001, 12:20 PM
#4
Re: How to compare 2 similar strings?
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
Posting Permissions
- You may not post new threads
- You may not post replies
- You may not post attachments
- You may not edit your posts
-
Forum Rules
|
Click Here to Expand Forum to Full Width
|