PC Review


Reply
Thread Tools Rating: Thread Rating: 1 votes, 5.00 average.

C++/CLI - Integers and text boxes

 
 
New Member
Join Date: Jan 2009
Posts: 1
 
      23rd Jan 2009
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 by Yippiekaiaii; 23rd Jan 2009 at 12:40 PM..
 
Reply With Quote
 
 
 
 
New Member
Join Date: Feb 2009
Posts: 1
 
      23rd Feb 2009
twidth = double::Parse(textBox1->Text);
 
Reply With Quote
 
 
 
Reply

Thread Tools
Rate This Thread
Rate This Thread:

Posting Rules
You may not post new threads
You may not post replies
You may not post attachments
You may not edit your posts

BB code is On
Smilies are On
[IMG] code is On
HTML code is Off
Trackbacks are On
Pingbacks are On
Refbacks are Off


Similar Threads
Thread Thread Starter Forum Replies Last Post
Aligning check boxes and text boxes with regular text =?Utf-8?B?c3NiZWxs?= Microsoft Word Document Management 1 28th Mar 2007 02:12 AM
RE: Aligning check boxes and text boxes with regular text =?Utf-8?B?U2ltb24gSm9uZXMgW01TRExd?= Microsoft Word Document Management 0 28th Mar 2007 12:17 AM
A list of Consecutive Integers, can I search for missing integers =?Utf-8?B?Q00=?= Microsoft Excel Worksheet Functions 4 2nd Sep 2005 06:38 PM
unable to search Text only Integers =?Utf-8?B?YWU=?= Microsoft ASP .NET 4 30th Aug 2004 02:34 PM
write 1-dimensional array of integers to text file RB Smissaert Microsoft Excel Programming 3 12th Oct 2003 05:56 PM


Features
 

Advertising
 

Newsgroups
 


All times are GMT +1. The time now is 03:25 PM.