View Full Version : Solved: Test Multiple Variable for Same Result

12-30-2008, 12:54 PM
What's the best way to test multiple variable to see if they have the same value?


Dim Var1 as Long
Dim Var2 as Long
Dim Var3 as Long
Dim Var4 as Long

If all 4 Variables are the same Then
Goto Here
Goto There
End if

What's the best way to write the line in Red? Thanks.

12-30-2008, 02:26 PM
There are many ways to test this. One way is like this:
Sub Test()
Dim a As Integer, x As Integer, y As Integer, b As Integer
a = 1
b = 1
x = 1
y = 1
If (a = b And b = x And x = y) Then
MsgBox "Match!"
End If
End Sub