Articles

This algorithm shows a converting hexadecimal value to the decimal value.

function HexToDec(Str: string): Integer;
var
  i, M: Integer;
begin
  Result:=0;
  M:=1;
  Str:=AnsiUpperCase(Str);
  for i:=Length(Str) downto 1 do
  begin
    case Str[i] of
      '1'..'9': Result:=Result+(Ord(Str[i])-Ord('0'))*M;
      'A'..'F': Result:=Result+(Ord(Str[i])-Ord('A')+10)*M;
    end;
    M:=M shl 4;
  end;
end;

procedure TForm1.Button1Click(Sender: TObject);
begin
  if Edit1.Text<>'' then
    Label2.Caption:=IntToStr(HexToDec(Edit1.Text));
end;