Jump to content
Xtreme .Net Talk

Recommended Posts

Posted

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

Guest mutant
Posted

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.

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.

Posted

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

Guest mutant
Posted

So you could just check the value of that integer. If it negative then make boolean false and if it positive make it true.

if somenumber = -100 then booleanvalue = false
if somenumber = 100 then booleanvalue = true

Posted

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

 

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

Code today gone tomorrow!
Guest mutant
Posted

Well, I just gave an example, he should know what I mean.

:)

Join the conversation

You can post now and register later. If you have an account, sign in now to post with your account.

Guest
Reply to this topic...

×   Pasted as rich text.   Paste as plain text instead

  Only 75 emoji are allowed.

×   Your link has been automatically embedded.   Display as a link instead

×   Your previous content has been restored.   Clear editor

×   You cannot paste images directly. Upload or insert images from URL.

×
×
  • Create New...