Link to home
Start Free TrialLog in
Avatar of twilight_prince
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.
Avatar of Igor UL7AAjr
Igor UL7AAjr
Flag of Kazakhstan image

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.
Avatar of Epsylon
Epsylon

Use

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


Regards,

Eps.
Epsylon;)
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...
Avatar of kretzschmar
its all said
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;
  ....
>LOCK<
ASKER CERTIFIED SOLUTION
Avatar of Epsylon
Epsylon

Link to home
membership
This solution is only available to members.
To access this solution, you must be a member of Experts Exchange.
Start Free Trial