Logical Operation

vinnie881

Well-known member
Joined
Sep 3, 2006
Messages
152
Programming Experience
3-5
Is there any way in vb.net to do a equation similiar to

if 1 = 1 = 1 = 1 then
debug.write("Value is true")
else
debug.write("Value is false")
end if

if 1=1=1=2 then
debug.write("Value is true")
else
debug.write("Value is false")




The first "IF" would come out to true because all values are equal (1 = 1)

but in the second would come out to false because of the (1 =2 ) meaning that all of the values were not equal.

Is there anyway to do something similar to this in vb.net?
 
I'd probably use an AndAlso for this.

VB.NET:
        If 1 = 1 AndAlso 1 = 1 AndAlso 1 = 1 AndAlso 1 = 1 Then
            Debug.Write("Value is true")
        Else
            Debug.Write("Value is false")
        End If

        If 1 = 1 AndAlso 1 = 1 AndAlso 1 = 1 AndAlso 1 = 2 Then
            Debug.Write("Value is true")
        Else
            Debug.Write("Value is false")
        End If

But maybe you're trying to do something different than I think you are.
 
Back
Top