x
Solved

converting integer to ascii

Posted on 2000-04-03
Medium Priority
475 Views
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.
0
Question by:twilight_prince

LVL 9

Expert Comment

ID: 2679916
Let suppose you have two TEdit controls on your form.
First - where you type number (0..200)
Second - where you want to see a char.
then you need code
------
begin
Edit2.Text:=Char(StrToInt(Edit1.Text));
end;
-----
Cheers,
Igor.
0

LVL 13

Expert Comment

ID: 2679926
Use

Var
value: Byte;
Begin
value := 65;
Label1.Caption := Chr(value);
End;

Regards,

Eps.
0

LVL 9

Expert Comment

ID: 2679935
Epsylon;)
Ooops....
0

LVL 13

Expert Comment

ID: 2679937
Instead of defining value as Byte, you can also define it as Integer, but Chr only accept values from 0 to 255.
0

LVL 13

Expert Comment

ID: 2679942
:o)

We don't have the same answer, but I'll withdraw mine...
0

LVL 27

Expert Comment

ID: 2680944
its all said
chr() is the function you need
0

LVL 10

Expert Comment

ID: 2685494
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;
....
0

LVL 13

Expert Comment

ID: 2688230
>LOCK<
0

LVL 13

Accepted Solution

Epsylon earned 400 total points
ID: 2688231
>LOCK<
0

Featured Post

Question has a verified solution.

Are you are experiencing a similar issue? Get a personalized answer when you ask a related question.

Have a better answer? Share it in a comment.