IntToHex (C++)

From RAD Studio Code Examples
Jump to: navigation, search

Description

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.

Code

void __fastcall TForm1::Button1Click(TObject *Sender)
{
  Label1->Caption = "";
  for (int i = 1; i <= Edit1->Text.Length(); i++)
  {
	try
	{
	  Label1->Caption =
		Label1->Caption +
		IntToHex(Byte(Edit1->Text[i]),2) + ' ';
	}
	catch (...)
	{
	  Beep();
	}
  }
}

Uses