Converting integers to booleans?

Hornet

Newcomer
Joined
May 1, 2003
Messages
16
Location
Rumst - Belgium
Is there in VB.NET a function to convert an integer to a boolean?

Now, I'm making a console application and I become on the end of the program an integer as resultat.


Then the program can say to lines: "Yes, you are in your right" or "No, you aren't in your right". But how can I convert that resultat (=integer) to a boolean? :confused:

Greetz,

Hornet
 
Boolean accepts values of 0 and 1, where 0 is false and 1 is true. So you can just assign the value of the integer to boolean.
Visual Basic:
dim boole as boolean
boole = 1 'true
'or
boole = 0 'false
if you go higher than 1 it will display true all the time. And if you go lower then 0 it will be true also.
 
Uhmm, I have created a program that check if you must pay or not.

Sometimes you must pay money and sometimes you can get money.

So, that integer can be a value as -100. Then the boolean must be 0 (=false). :D

You see?

Greetz,

Hornet
 
So you could just check the value of that integer. If it negative then make boolean false and if it positive make it true.
Visual Basic:
if somenumber = -100 then booleanvalue = false
if somenumber = 100 then booleanvalue = true
 
id use a if else statement because nothing is set if the number not equals as it the number has to be -100 or 100

Visual Basic:
Function Checknumber (ByVal CheckNumber As Integer) As Boolean
    If CheckNumber <= -100 then
        Return False
    Else
        Return True
    End if
End Function
 
Back
Top