Click to See Complete Forum and Search --> : double variable simple question


lior6543
January 16th, 2005, 02:46 PM
I added a double variable to a label in my form like this:

double dbVar;
System::Windows::Forms::Label * labelTotal;

labelTotal->Text = dbVar.ToString();

the code works fine but i got one question.
in case the value of dbVar is 5.43 it is ok.
but if it is 5 , i want it to be 5.00, how can i do this?

Jinto
January 17th, 2005, 06:23 AM
http://msdn.microsoft.com/library/default.asp?url=/library/en-us/cpguide/html/cpconStandardNumericFormatStrings.asp

double myDb = 5;
String* text = myDb.ToString("F2");

Hope this helps..

lior6543
January 17th, 2005, 07:08 AM
yeah it did, thanks!