0

Hello,
I am new to using windows form application in c++ and i am having a problem with making my program work. I have three textBars and one button. The first textBar is for the user to input a double. When the button is pressed i want it to perform the mathmatical task: textBox1 * 150 / 60, and show the results in textBox2. Then, textBox2 * 20 / 60 results in textBox3. All with the one button click.

2
Contributors
4
Replies
5
Views
5 Years
Discussion Span
Last Post by Ancient Dragon
0

What version of Visual Studio are you using? M$ dropped support for c++ Windows
Forms in VS 2012.

textbox.Text = "something" will set the text in a textbox, read this link for all properties/methods.

So to make the calculation just convert the text in the textbox to an int, make calculations, convert result to a string, and assign back to the textbox. Since you are working with CLR/C++ I assume you already know how to to most of that.

Edited by Ancient Dragon

0

Im using VS 2010 prof. Thanks for the help.

Edited by Bowdown28

0

Ok i got the code to work, but how do i get my decimals to round to the second decimal place after the decimal like 1.11?

#pragma endregion
        double x,y,z;
private: System::Void button1_Click(System::Object^  sender, System::EventArgs^  e) {
            x=System::Convert::ToDouble(this->textBox1->Text);
            y= x*150/60;
            this->textBox2->Text = System::Convert::ToString(y);
            z= y*20/60;
            this->textBox3->Text = System::Convert::ToString(z); 
            }
private: System::Void button2_Click(System::Object^  sender, System::EventArgs^  e) {
             this->textBox1->Text="";
             this->textBox2->Text="";
             this->textBox3->Text="";
         }
This question has already been answered. Start a new discussion instead.
Have something to contribute to this discussion? Please be thoughtful, detailed and courteous, and be sure to adhere to our posting rules.