
其实,以上程序还有一个问题没有解决,就是当你输入大于32位的数值时程序将会出错,这个问题留待以后基础打牢点再解决了,呵呵。。
unit Unit1;
interface
uses
Windows, Messages, SysUtils, Variants, Classes, Graphics, Controls, Forms,
Dialogs, StdCtrls;
type
TForm1 = class(TForm)
Edit1: TEdit;
StaticText1: TStaticText; //这组件跟标签label效果差不多
StaticText2: TStaticText;
Edit2: TEdit;
Button1: TButton;
Button2: TButton;
procedure Button1Click(Sender: TObject);
procedure Button2Click(Sender: TObject);
private
{ Private declarations }
public
{ Public declarations }
end;
var
Form1: TForm1;
implementation
{$R *.dfm}
procedure TForm1.Button1Click(Sender: TObject); //都是delphi自带函数,没什么好说的
var
a:Integer;
begin
a:=StrToInt(Edit1.Text);
Edit2.Text:=IntToHex(a,1);
end;
procedure TForm1.Button2Click(Sender: TObject); //都是delphi自带函数,没什么好说的
var
i:Integer;
begin
i:=strtoint('$'+(Edit2.Text)); //加'$'后,原本的字符串就成了16进制数
Edit1.Text:=IntToStr(i);
end;
end.
浙公网安备 33010602011771号