还是不行。编译就通不过。出错信息是: [Error] Unit1.pas(30): Incompatible types [Fatal Error] Project2.dpr(5): Could not compile used unit 'Unit1.pas' 这可怎么办?
var S: string; ch: Char; begin S := Edit1.text; ch := Pchar(s)[0]; Edit2.text := IntToStr(ord(ch)); end;
edit输入的是字符串,你的关键是取得第一个字符。 procedure TForm1.Button1Click(Sender: TObject); var ss :string[100]; ch:char; begin ss:=edit1.Text ; ch:=ss[1]; edit2.Text:=inttostr(ord(ch)); end;end. 我调试通过了。你试一试看。
用edit2.text:=inttostr(ord(edit1.text));总是出错。你们试过吗?
[Error] Unit1.pas(30): Incompatible types
[Fatal Error] Project2.dpr(5): Could not compile used unit 'Unit1.pas'
这可怎么办?
S: string;
ch: Char;
begin
S := Edit1.text;
ch := Pchar(s)[0];
Edit2.text := IntToStr(ord(ch));
end;
procedure TForm1.Button1Click(Sender: TObject);
var
ss :string[100];
ch:char;
begin
ss:=edit1.Text ;
ch:=ss[1];
edit2.Text:=inttostr(ord(ch));
end;end.
我调试通过了。你试一试看。