.NET Development
 
Forums: » Register « |  User CP |  Games |  Calendar |  Members |  FAQs |  Sitemap |  Support | 
 
User Name:
Password:
Remember me
 
Go Back   Dev Articles Community ForumsProgramming.NET Development

Reply
Add This Thread To:
  Del.icio.us   Digg   Google   Spurl   Blink   Furl   Simpy   Y! MyWeb 
Thread Tools Search this Thread Display Modes
 
Unread Dev Articles Community Forums Sponsor:
  #1  
Old October 30th, 2003, 04:53 AM
mtzal mtzal is offline
Junior Member
Dev Articles Newbie (0 - 499 posts)
 
Join Date: Oct 2003
Posts: 8 mtzal User rank is Just a Lowly Private (1 - 20 Reputation Level) 
Time spent in forums: < 1 sec
Reputation Power: 0
varable type casting, how to convert a string variable

I am using c#.
I have a windows form with two texBoxes called textBox1 and textBox2.I also have a button called button1.
My problem is that i want to add the numbers in the textBox1 and textbox2 and present them somewhere else when the user presses the button1.
I dont know how to convets the text of the textboxes to an int variable so i can add them.

I think that this must be something very easy, but please help me.

Reply With Quote
  #2  
Old October 30th, 2003, 08:36 AM
rdoekes rdoekes is offline
Contributing User
Dev Articles Newbie (0 - 499 posts)
 
Join Date: Jul 2002
Location: Strasbourg, France
Posts: 181 rdoekes User rank is Just a Lowly Private (1 - 20 Reputation Level) 
Time spent in forums: 5 m 20 sec
Reputation Power: 7
Send a message via AIM to rdoekes Send a message via Yahoo to rdoekes
Code:
int myAddition = Convert.ToInt32(textBox1.Text) + 
     Convert.ToInt32(textBox2.Text)
__________________
- Rogier Doekes

Reply With Quote
  #3  
Old November 19th, 2003, 08:39 AM
Schnicka Schnicka is offline
Junior Member
Dev Articles Newbie (0 - 499 posts)
 
Join Date: Oct 2003
Location: Germany
Posts: 9 Schnicka User rank is Just a Lowly Private (1 - 20 Reputation Level) 
Time spent in forums: < 1 sec
Reputation Power: 0
You can also use:
Code:
int Addition = int.Parse(textBox1.Text) + int.Parse(textBox2.Text);

Reply With Quote
  #4  
Old June 1st, 2004, 03:43 AM
topi topi is offline
Registered User
Dev Articles Newbie (0 - 499 posts)
 
Join Date: May 2004
Posts: 6 topi User rank is Just a Lowly Private (1 - 20 Reputation Level) 
Time spent in forums: < 1 sec
Reputation Power: 0
other tips

code: from vb.net

Dim num AsInteger = CInt(TextBox1.Text) + CInt(TextBox2.Text)


Reply With Quote
Reply

Viewing: Dev Articles Community ForumsProgramming.NET Development > varable type casting, how to convert a string variable


Thread Tools  Search this Thread 
Search this Thread:

Advanced Search
Display Modes  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

vB code is On
Smilies are On
[IMG] code is On
HTML code is Off
View Your Warnings | New Posts | Latest News | Latest Threads | Shoutbox
Forum Jump


Forums: » Register « |  User CP |  Games |  Calendar |  Members |  FAQs |  Sitemap |  Support | 
  
 





© 2003-2008 by Developer Shed. All rights reserved. DS Cluster 2 hosted by Hostway
Stay green...Green IT