CompConversion (Delphi)

From RAD Studio Code Examples
Jump to: navigation, search

Description

This example evidences the Comp conversion functions.

Code

procedure TForm2.Button1Click(Sender: TObject);
var
  CompValue: Comp;
  CurrencyValue: Currency;
begin
  try
    CompValue := StrToInt64(Edit1.Text);
    CurrencyValue := CompToCurrency(CompValue);
    Edit2.Text := CurrToStr(CurrencyValue);
  except
    MessageDlg('Enter a signed integer with abs value <= 9 * 10**18', mtError, [mbOK], 0);
  end;
end;

procedure TForm2.Button2Click(Sender: TObject);
var
  CompValue: Comp;
  DoubleValue: Double;
begin
  try
    CompValue := StrToInt64(Edit3.Text);
    DoubleValue := CompToDouble(CompValue);
    Edit4.Text := FloatToStr(DoubleValue);
  except
    MessageDlg('Enter a signed integer with abs value <= 9 * 10**18', mtError, [mbOK], 0);
  end;
end;

Uses

See Also

Personal tools
Assistance