For Newbie

Tuesday, 15 November 2011

how to convert string to hexadecimal format with delphi

string to hexa decimal delphi




The following is how to convert string to hexadecimal format with delphi


Function declaration:



function StrHex(inp: String): String;
var
  i: Integer;
  cStr: String;
begin
  for i:= 1 to Length(inp) do cStr:= cStr + IntToHex(Ord(inp[i]), 2) + ' ';
  Result:= cStr;
end;

the implementation
procedure TForm1.Button1Click(Sender: TObject);
begin
  with Memo1.Lines do
  begin
    Clear;
    Add(StrHex(Edit1.Text));
  end;
end;

Share on Facebook
Share on Twitter
Share on Google+

Related : how to convert string to hexadecimal format with delphi