RAD Studio VCL Reference
ContentsIndex
PreviousUpNext
System.CompToCurrency Function

Converts a Comp value to a Currency value.

Pascal
function CompToCurrency(Value: Comp): Currency; cdecl;
C++
__cdecl Currency CompToCurrency(Comp Value);

CompToCurrency converts a Comp value into a Currency value containing the decimal representation of that number.  

C++ Examples: 

 

/*
This example demonstrates Comp conversion functions.
*/

void __fastcall TForm2::Button1Click(TObject *Sender)
{
    Comp CompValue;
    Currency CurrencyValue;

    try {
        CompValue = StrToInt64(Edit1->Text);
        CurrencyValue = CompToCurrency(CompValue);
        Edit2->Text = CurrToStr(CurrencyValue);
        }
    catch (...) {
        MessageDlg("Enter a signed integer with abs value <= 9 * 10**18", mtError,
            TMsgDlgButtons() << mbOK, 0);
    }
}
//---------------------------------------------------------------------------

void __fastcall TForm2::Button2Click(TObject *Sender)
{
    Comp CompValue;
    Double DoubleValue;

    try {
        CompValue = StrToInt64(Edit3->Text);
        DoubleValue = CompToDouble(CompValue);
        Edit4->Text = FloatToStr(DoubleValue);
        }
    catch (...) {
        MessageDlg("Enter a signed integer with abs value <= 9 * 10**18", mtError,
            TMsgDlgButtons() << mbOK, 0);
    }
}

 

Delphi Examples: 

{
This example demonstrates Comp conversion functions.
}

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;

 

Copyright(C) 2009 Embarcadero Technologies, Inc. All Rights Reserved.
What do you think about this topic? Send feedback!