C++/CLI - Integers and text boxes

Joined
Jan 23, 2009
Messages
1
Reaction score
0
Hello All

I am using MS Visual Studio 2008 and am a complete beginer and am trying to teach myself.

I have created a Windows Form Application from the CLR menu.

I am having a problem with using text boxes and integers together. I want to be able to take an integer from one text box and add it to the integer entered into another text box.

What ever i try it will not build because the variables I am setting are int and it wont convert the string from the text into an int.

Can anyone tell me how to take the integer in textBox1 and assign it to a variable called var1, when var1 is declared as an int variable. I want to put it in the button click event (of which I know where to put the code)

Any help will be very much appraciated.

EDIT- Here is my current code that isnt working

private: System::Void button1_Click(System::Object^ sender, System::EventArgs^ e) {
double twidth; //tile width
double thight; //tile hight

twidth = textBox1->Text->ToDouble(0);
thight = textBox2->Text->ToDouble(0);

}

and here is the error message when building :

error C2039: 'ToDouble' : is not a member of 'System::String'
 
Last edited:
Back
Top