|
|
|||||||||
|
|||||||||
|
|||||||||
| |
|||
| |||||||||
![]() |
|
|
«
Previous Thread
|
Next Thread
»
|
Thread Tools | Search this Thread | Display Modes |
|
#1
|
|||
|
|||
|
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. |
|
#2
|
|||
|
|||
|
Code:
int myAddition = Convert.ToInt32(textBox1.Text) +
Convert.ToInt32(textBox2.Text)
__________________
- Rogier Doekes |
|
#3
|
|||
|
|||
|
You can also use:
Code:
int Addition = int.Parse(textBox1.Text) + int.Parse(textBox2.Text); |
|
#4
|
|||
|
|||
|
other tips
code: from vb.net
Dim num AsInteger = CInt(TextBox1.Text) + CInt(TextBox2.Text) |
![]() |
| Viewing: Dev Articles Community Forums > Programming > .NET Development > varable type casting, how to convert a string variable |
| Thread Tools | Search this Thread |
| Display Modes | Rate This Thread |
|
|
|
|