It may seem silly, but I was stuck and I had no luck on the Internet for this to happen. I have a method that I want to check to make sure that both numbers entered are positive:
Public Function BothPositive(ByVal num1 As Integer, ByVal num2 As Integer) As Boolean If (num1 And num2) > 0 Then Return True Else Return False End If End Function
Now, if I were to enter some numbers in
- BothPositive (1,1) = True
- BothPositive (1,2) = False
- BothPositive (-10, 10) = True
Why is this? What happens to the order of operations in the comparison statement, or what does the AND try to compare with? I do not understand why this will not work.
EDIT: I understand how to work, but my question is - why is this happening? I want to know what happens, what causes it.
source share