|
-
Jun 2nd, 2006, 02:26 PM
#1
Thread Starter
Frenzied Member
[RESOLVED] Return values from boolean
Hi,
Is there any builtin function which will give value 1 for True and value 0 to false. I have following function:
VB Code:
Private Function BoolToVal(ByVal blnTemp As Boolean) As Integer
'This function will return 1 if the value is true else will return 0
If blnTemp = True Then
BoolToVal = 1
Else
BoolToVal = 0
End If
End Function
-
Jun 2nd, 2006, 02:33 PM
#2
Addicted Member
Re: Return values from boolean
...how about "val = ABS(blnVal)"? Any TRUE boolean in VB is = -1, so just remove the sign...
-
Jun 2nd, 2006, 02:34 PM
#3
Thread Starter
Frenzied Member
Re: Return values from boolean
Found a solution myself. Abs(Int(true)) will return 1 and Abs(Int(false)) will return 0
Anyway,
Thanks.
-
Jun 2nd, 2006, 02:34 PM
#4
Thread Starter
Frenzied Member
Re: Return values from boolean
 Originally Posted by sigid
...how about "val = ABS(blnVal)"? Any TRUE boolean in VB is = -1, so just remove the sign...
Thanks, I already found the solution.
-
Jun 2nd, 2006, 04:19 PM
#5
Re: [RESOLVED] Return values from boolean
Cint(True) returns negative one cause all the bits are set to 1 including the highest bit (which determines +/-).
So use...
Debug.Print (CInt(yourbool) AND 1)
Posting Permissions
- You may not post new threads
- You may not post replies
- You may not post attachments
- You may not edit your posts
-
Forum Rules
|
Click Here to Expand Forum to Full Width
|