Fórum Integer to boolean... #161175
20/05/2003
0

Petrified Eyes
Curtir tópico
+ 0Posts
20/05/2003
Okama
1 2 3 4 5 6 7 | function IntToBoolean(Num: Integer):Boolean; begin if Num = 1 then Result := True else Result := False; end; |
Gostei + 0
20/05/2003
Aroldo Zanela
1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 20 | procedure TForm1.Button1Click(Sender: TObject); var Flag: Boolean; begin // Type casting Flag := Boolean(1); if Flag then ShowMessage(´Verdadeiro´); Flag := Boolean(0); if not Flag then ShowMessage(´Falso´); // Valor booleano recebe o resultado da comparação lógica Flag := 1 = 1; if Flag then ShowMessage(´Verdadeiro´); Flag := 1 = 0; if not Flag then ShowMessage(´Falso´); end; |
Gostei + 0
20/05/2003
Aroldo Zanela
1 2 3 4 | function IntToBoolean(Num: Integer):Boolean; begin Result := Num = 1; end; |
Gostei + 0
20/05/2003
Jairroberto
Basta fazer um [i:23fed91436]cast[/i:23fed91436] no valor inteiro para o tipo Boolean:
VariavelBoolean := Boolean(VariavelInteira);
Se ´VariavelInteira´ for 0 (zero) o resultado será False, se for diferente de 0 (zero) o resultado será True.
Sendo assim, você pode escrever algo do tipo:
if Boolean(StrToInt(Edit1.Text)) then
ShowMessage(´True´)
else
ShowMessage(´False´);
Um abraço,
Jair
Gostei + 0
Clique aqui para fazer login e interagir na Comunidade :)