Casting a boolean to an integer returns -1 for true?

前端 未结 9 804
醉梦人生
醉梦人生 2020-12-01 05:30

I am working with some VB.NET code that seems to be casting a boolean value to an integer using CInt(myBoolean). The odd thing that is happening is that it retu

9条回答
  •  北海茫月
    2020-12-01 05:51

    I hope that is can help others work with Booleans inside VB.NET. Just as a better way to write the VB.NET that Roger wrote:

    Public Function BoolToMySql(bVal As Boolean) As Integer
       return  If(bVal, 1, 0)
    End Function
    

提交回复
热议问题