|
-
Sep 1st, 2000, 07:08 AM
#1
Thread Starter
New Member
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.
-
Sep 1st, 2000, 07:16 AM
#2
Frenzied Member
Code:
If Variable1 = Variable2 Then
MsgBox "The Variables are the same!"
Else
MsGBox "They Differ!"
End If
Jop - validweb.nl
Alcohol doesn't solve any problems, but then again, neither does milk.
-
Sep 1st, 2000, 07:19 AM
#3
Member
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
VB 6, SQL, Java, AutoLISP, Avenue and on a good day AML
-
Sep 1st, 2000, 07:21 AM
#4
Guru
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?
-
Sep 1st, 2000, 07:23 AM
#5
_______
<?>
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.
"A myth is not the succession of individual images,
but an integerated meaningful entity,
reflecting a distinct aspect of the real world."
___ Adolf Jensen
-
Sep 1st, 2000, 08:10 AM
#6
Frenzied Member
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
Jop - validweb.nl
Alcohol doesn't solve any problems, but then again, neither does milk.
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
|