unit IntToHex;

interface

uses
  Windows, Messages, SysUtils, Variants, Classes, Graphics, Controls, Forms,
  Dialogs, StdCtrls;

type
  TForm1 = class(TForm)
    Button1: TButton;
    Edit1: TEdit;
    Label1: TLabel;
    procedure Button1Click(Sender: TObject);
  private
    { Private declarations }
  public
    { Public declarations }
  end;

var
  Form1: TForm1;

implementation

{$R *.dfm}

// BeginExample: IntToHex
// Routine: SysUtils.IntToHex
// Routine: System.Length

// BeginCode
{
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 +
        SysUtils.IntToHex(Byte(Edit1.Text[i]),2) + ' ';
    except
      Beep;
    end;
  end;
end;
// EndCode
// EndExample: IntToHex
end.
