DelphiBasics
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
IntToStrConvert an integer into a string
StrToIntConvert an integer string into an Integer value
 Download this web site as a Windows program.




 
Example code : Convert an integer to a hex format
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;
Show full unit code
  1234 decimal = 4D2
  1234 decimal = 000004D2
 
Delphi Programming © Neil Moffatt . All rights reserved.  |  Home Page