![]() |
Math Functions |
To convert the value of a string to floating number, use the AnsiString::ToDouble() method. Its syntax is: double __fastcall ToDouble() const; Here is an example: //---------------------------------------------------------------------------
void __fastcall TForm1::Button1Click(TObject *Sender)
{
double Value1 = Edit1->Text.ToDouble();
double Value2 = Edit2->Text.ToDouble();
double Value3 = Value1 + Value2;
Edit3->Text = Value3;
}
//---------------------------------------------------------------------------
Another function used to convert a string to a floating-point value is the StrToFloat() function whose syntax is: Extended __fastcall StrToFloat(const AnsiString S); This function takes one argument, which is the string to convert. The function returns a long double-precision value. Here is an example: //---------------------------------------------------------------------------
void __fastcall TForm1::Button1Click(TObject *Sender)
{
double Value1 = StrToFloat(Edit1->Text);
double Value2 = StrToFloat(Edit2->Text);
double Value3 = Value1 + Value2;
Edit3->Text = Value3;
}
//---------------------------------------------------------------------------
|
| Home | Copyright © 2004-2010 FunctionX, Inc. | |