boolean VB expression returning false for integer 1

Posted by Bill on Stack Overflow See other posts from Stack Overflow or by Bill
Published on 2011-01-17T19:34:59Z Indexed on 2011/01/17 19:53 UTC
Read the original article Hit count: 118

Filed under:

This is probably a really basic (no pun intended) question, but I can't seem to find an answer anywhere. Why does the result of func1 return False and func2 returns True? On every other test I have done, integer 1 is converted to boolean true and 0 to false. Works ok if I just set rtnValue to 1 or 0.

Public Function func1() As Boolean Dim rtnValue As Integer = 0 Return rtnValue = 1

End Function


Public Function func2() As Boolean
    Dim rtnValue As Integer = 0
    Return rtnValue = 0

End Function

© Stack Overflow or respective owner

Related posts about vb