Hornet Posted May 3, 2003 Posted May 3, 2003 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 Quote
Guest mutant Posted May 3, 2003 Posted May 3, 2003 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. Quote
Hornet Posted May 3, 2003 Author Posted May 3, 2003 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 Quote
Guest mutant Posted May 3, 2003 Posted May 3, 2003 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 Quote
a_jam_sandwich Posted May 3, 2003 Posted May 3, 2003 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 Quote Code today gone tomorrow!
Guest mutant Posted May 3, 2003 Posted May 3, 2003 Well, I just gave an example, he should know what I mean. :) Quote
Recommended Posts
Join the conversation
You can post now and register later. If you have an account, sign in now to post with your account.