IntToHex
The following example uses an edit control, a button, and a label on a form. When the button is clicked, the hexadecimal value of each character in the edit control is displayed in the label.
procedure TForm1.Button1Click(Sender: TObject);
var
i: Integer;
begin
Label1.Caption := '';
for i := 1 to Length(Edit1.Text) do
begin
try
Label1.Caption := Label1.Caption + IntToHex(Edit1.Text[i],2) + ' ';
except
Beep;
end;
end;
end;
正确应为:
procedure TForm1.Button1Click(Sender: TObject);
var
i: Integer;
begin
Label1.Caption := '';
for i := 1 to Length(Edit1.Text) do
begin
try
Label1.Caption := Label1.Caption + IntToHex(StrToInt(Edit1.Text[i]),2) + ' ';
except
Beep;
end;
end;
end;
本文介绍了一个使用Delphi编写的示例程序,该程序能够将文本框中每个字符转换为其对应的十六进制数值,并显示在标签上。通过这个简单的例子,读者可以了解如何在Delphi中使用IntToHex函数。
1万+

被折叠的 条评论
为什么被折叠?



