SmartPascal
IntToHex
Function
Convert an Integer into a hexadecimal string SysUtils unit
 function IntToHex ( DecimalValue : Integer; MinimumWidth : Integer ) : string;
Description
The IntToHex function converts a DecimalValue integer into a hexadecimal format sting of at least MinimumWidth characters wide.
 
The resulting string has no prefix character.
Related commands
IntToStr Convert an integer into a string
StrToInt Convert an integer string into an Integer value
 
Example code : Convert an integer to a hex format
// Full Unit code.
// -----------------------------------------------------------
// You must store this code in a unit called Unit1 with a form
// called Form1 that has an OnCreate event called FormCreate.
 
unit Unit1;
 
interface
 
uses
  SysUtils,   // Unit containing the IntToHex command
  Forms, Dialogs;
 
type
  TForm1 = class(TForm)
    procedure FormCreate(Sender: TObject);
  end;
 
var
  
Form1: TForm1;
 
implementation
{$R *.dfm} // Include form definitions
 
procedure TForm1.FormCreate(Sender: TObject);

begin
  // Display 123 decimal in hex with minimal width
  ShowMessage('1234 decimal = '+IntToHex(1234, 1));

  // Display 123 decimal in hex with fixed width
  ShowMessage('1234 decimal = '+IntToHex(1234, 8));
end;
 
end.
Hide full unit code
   1234 decimal = 4D2
   1234 decimal = 000004D2