PDA

Click to See Complete Forum and Search --> : vb casting boolean


bharatbkakkar
Feb 10th, 2006, 03:42 PM
can any one help me with the following issue:

when we cast boolean variable to integer true gets the value -1 instead of 1
eg:
dim a as boolean
dim b as integer

a= true
b=a
msgbox(b)

we will get -1 why it is so ?

si_the_geek
Feb 10th, 2006, 05:06 PM
Welcome to VBForums! :wave:

You get -1 because that is the value of True.

If you want to have 1 instead (and 0 for False) you can simply use the Abs function, eg:
b = Abs(a)