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 ?
Printable View
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 ?
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:
VB Code:
b = Abs(a)