 图5.3 根据ASCII码获得字母 主要代码如下: procedure TForm1.Button1Click(Sender: TObject); begin if (((StrToInt(Edit1.Text))>=65)and((StrToInt(Edit1.Text))<=90))or (((StrToInt(Edit1.Text))>=97)and((StrToInt(Edit1.Text))<=122)) then Edit2.Text:=chr(strtoint(edit1.Text)); end;
字母的ASCII码
本实例是用ord ()函数将字符转换成ASCII码。运行结果如图5.4所示。
 图5.4 获得字母的ASCII码 主要代码如下: procedure TForm1.Edit1KeyPress(Sender: TObject; var Key: Char); begin if not (key in ['a'..'z','A'..'Z',#8]) then key:=#0; if (Ord(key)>64)and(Ord(key)<123) then x:=IntToStr(Ord(key)); end; |