twilight_prince
asked on
converting integer to ascii
hi,
i want to be able to enter any number from 0 to 200 and i want to get the ascii character corrosponding to that number. how do can i do this? converting into bytes is ok as well but you would have to be explicit, i haven't used bytes before. how do i define a variable as a byte? but in the end i would prefer to do it without using bytes. so to reiterate, i want to be able to take an integer and get the ascii character that integer represents. please help.
thank you.
i want to be able to enter any number from 0 to 200 and i want to get the ascii character corrosponding to that number. how do can i do this? converting into bytes is ok as well but you would have to be explicit, i haven't used bytes before. how do i define a variable as a byte? but in the end i would prefer to do it without using bytes. so to reiterate, i want to be able to take an integer and get the ascii character that integer represents. please help.
thank you.
Use
Var
value: Byte;
Begin
value := 65;
Label1.Caption := Chr(value);
End;
Regards,
Eps.
Var
value: Byte;
Begin
value := 65;
Label1.Caption := Chr(value);
End;
Regards,
Eps.
Epsylon;)
Ooops....
Ooops....
Instead of defining value as Byte, you can also define it as Integer, but Chr only accept values from 0 to 255.
:o)
We don't have the same answer, but I'll withdraw mine...
We don't have the same answer, but I'll withdraw mine...
its all said
chr() is the function you need
chr() is the function you need
In Delphi all ordinal types are compatible:
var
b: Byte;
i: Integer;
m: 1..1000;
i64: Int64;
begin
b:=3;
i:=b; m:=i; i64:=m;
....
var
b: Byte;
i: Integer;
m: 1..1000;
i64: Int64;
begin
b:=3;
i:=b; m:=i; i64:=m;
....
>LOCK<
ASKER CERTIFIED SOLUTION
membership
This solution is only available to members.
To access this solution, you must be a member of Experts Exchange.
First - where you type number (0..200)
Second - where you want to see a char.
then you need code
------
begin
Edit2.Text:=Char(StrToInt(
end;
-----
Cheers,
Igor.