Help with number to string conversion
-
I've been working my way out of the console apps and I am now trying to learn how to use windows forms in visual studio 2008. Anyway, onward to the question. I am trying to display a numerical value as text in a label on a windows form. I looked around for an answer on the internet and I found some, but I couldn't get them to work for me. So I decided to start from scratch and just ask this forum for help. Here's the section of code I'm dealing with, I bolded my problem areas. Oh and to avoid confusion, click this: http://img100.imageshack.us/img100/4479/form1w.jpg[^]. Its a picture of my form with all of the variables and etc labeled.
private: System::Void numberDisp_Click(System::Object^ sender, System::EventArgs^ e)
{
numberDisp->Text = ticketNumber->Value
}
private: System::Void priceDisp_Click(System::Object^ sender, System::EventArgs^ e)
{
//Variable
int tickNum = 0;
double price = 0;//Get # of tickets tickNum = ticketNumber->Value; //Calculate Price if (locB->Checked == true) { price = tickNum \* 75; } if (locP->Checked == true) { price = tickNum \* 30; } if (locL->Checked == true) { price = tickNum \* 21; } //Display Price **priceDisp->Text = price;** }
-
I've been working my way out of the console apps and I am now trying to learn how to use windows forms in visual studio 2008. Anyway, onward to the question. I am trying to display a numerical value as text in a label on a windows form. I looked around for an answer on the internet and I found some, but I couldn't get them to work for me. So I decided to start from scratch and just ask this forum for help. Here's the section of code I'm dealing with, I bolded my problem areas. Oh and to avoid confusion, click this: http://img100.imageshack.us/img100/4479/form1w.jpg[^]. Its a picture of my form with all of the variables and etc labeled.
private: System::Void numberDisp_Click(System::Object^ sender, System::EventArgs^ e)
{
numberDisp->Text = ticketNumber->Value
}
private: System::Void priceDisp_Click(System::Object^ sender, System::EventArgs^ e)
{
//Variable
int tickNum = 0;
double price = 0;//Get # of tickets tickNum = ticketNumber->Value; //Calculate Price if (locB->Checked == true) { price = tickNum \* 75; } if (locP->Checked == true) { price = tickNum \* 30; } if (locL->Checked == true) { price = tickNum \* 21; } //Display Price **priceDisp->Text = price;** }
Try using the ToString method:
priceDisp->Text = price.ToString();
Also, maybe you could use the correct forum[^] - you're more likely to get the correct answer there.
Java, Basic, who cares - it's all a bunch of tree-hugging hippy cr*p
-
Try using the ToString method:
priceDisp->Text = price.ToString();
Also, maybe you could use the correct forum[^] - you're more likely to get the correct answer there.
Java, Basic, who cares - it's all a bunch of tree-hugging hippy cr*p
Bah, sorry about the forum :( This is the second time I've done this (accident).