-
I have two variables one includes Data form the registry and in the other I have put Data from a file.
And Now I would like to compare these two variables.
Have anyone a good idear with I can to this.
Variable one:
Home;Test;Room
Variable one:
Home;Test;Room
In advance the cordial owing to.
-
Code:
If Variable1 = Variable2 Then
MsgBox "The Variables are the same!"
Else
MsGBox "They Differ!"
End If
-
You could use InStr it would just tell you if string1 is in string2.
InStr(1, string1, string2, 1)
or
if (string1 = string2) then
'do something
end if
HTH
Phil
-
Quote:
Originally posted by Jop
Code:
If Variable1 = Variable2 Then
MsgBox "The Variables are the same!"
Else
MsGBox "They Differ!"
End If
This does a case-sensitive comparison. This means, "abc" is different from "ABC".
If you want it case-insensitive ("abc"="ABC"="aBc", etc.) then at the very very very top of the code (first line of the code window), add this line.
Code:
Option Compare Text
Alrighty? :rolleyes:
-
<?>
Code:
StrComp Function Example
This example uses the StrComp function to return the results of a string comparison.
If the third argument is 1, a textual comparison is performed. If the third argument is 0 or omitted, a binary comparison is performed.
Dim MyStr1, MyStr2, MyComp
MyStr1 = "ABCD"
MyStr2 = "abcd"
MyComp = StrComp(MyStr1, MyStr2, 1) ' Returns 0.
MyComp = StrComp(MyStr1, MyStr2, 0) ' Returns -1.
MyComp = StrComp(MyStr2, MyStr1) ' Returns 1.
-
If you want to use case-insesitive compare you could also do:
Code:
If lcase(String1) = lcase(String2) Then
MsgBox "SAME!"
Else
MsgBox "Different!"
End If