Tycoon Talk
Become a Big fish!
The number 1 forum for online business!
Post topics, ask questions, share your knowledge.
Tycoon Talk is part of Freelancer.com - find skilled workers online at a fraction of the cost.

.NET Forum


You are currently viewing our .NET Forum as a guest. Please register to participate.
Login



Reply
adding value to the .Text
Old 10-09-2008, 02:38 AM adding value to the .Text
Nazi370's Avatar
Skilled Talker

Posts: 70
Name: Nazirul
Trades: 0
hi..
how do we add integer from the input

for example...

Dim Total

Total = txtButton1.Text + txtButton2.Text

i have to ask the user to input integer into the text box.. then adding the value.. but result is concat

for eg..

if txtButton1.Text = 5 and txtbutton2.Text = 9

Total will be 59...

how do we calculate in .NET , thanks
Nazi370 is offline
Reply With Quote
View Public Profile
 
 
Register now for full access!
Old 10-09-2008, 05:23 AM Re: adding value to the .Text
chrishirst's Avatar
Missing! presumed drunk.

Posts: 41,519
Name: Chris Hirst
Location: Blackpool. UK
Trades: 0
convert the textbox value to an integer
__________________
Chris. ->> Links are advertising NOT optimising!! <<-
A foolish consistency is the hobgoblin of little minds
Thought for today:- I SEO the only industry where all the cowboys are Indians?
chrishirst is online now
Reply With Quote
View Public Profile Visit chrishirst's homepage!
 
Old 10-10-2008, 01:23 PM Re: adding value to the .Text
Learning Newbie's Avatar
Defies a Status

Latest Blog Post:
Astounding Republican Paranoia
Posts: 5,662
Name: John Alexander
Trades: 0
int someValue = int.Parse(textbox1.Text);
__________________

Please login or register to view this content. Registration is FREE


Please login or register to view this content. Registration is FREE
Learning Newbie is offline
Reply With Quote
View Public Profile
 
Old 10-11-2008, 03:51 AM Re: adding value to the .Text
Nazi370's Avatar
Skilled Talker

Posts: 70
Name: Nazirul
Trades: 0
i have read the .Parse in the help but it still confusing me..

this is what i have done in the calculation..

let say: txtFoods.Text and txtDrinks.Text

where txtFoods = 50 and txtDrinks = 20

Dim Foods As Integer = txtFoods.Text
Dim Drinks As Integer = txtDrinks.Text
Dim Total As Integer

Total = Foods + Drinks

/* it works fine.. hopefully..

but using the Parse...

Code:
int someValue = int.Parse(textbox1.Text)
...will make me looks smart
Nazi370 is offline
Reply With Quote
View Public Profile
 
Old 10-16-2008, 03:47 PM Re: adding value to the .Text
Learning Newbie's Avatar
Defies a Status

Latest Blog Post:
Astounding Republican Paranoia
Posts: 5,662
Name: John Alexander
Trades: 0
Quote:
Originally Posted by Nazi370 View Post
i have read the .Parse in the help but it still confusing me..
You should read up on data types. VB hides this from you. Think of it like people - if you want a baby, you need 2 people to make one, but they have to be the right type of people. You need a man and a woman. If you have 2 people, but they're both women, they can't make a baby. If you want to do math, you need 2 pieces of data, but now they both have to be the same type, and it has to be a numeric type. int.Parse(string) takes a string representation of numeric data and turns it into an integer. double.Parse(string) does the same thing, but gives a double precision decimal result. Et cetera. Because text boxes let a user enter text, which is string data, it must be converted into numbers before you're able to do math on it.
__________________

Please login or register to view this content. Registration is FREE


Please login or register to view this content. Registration is FREE
Learning Newbie is offline
Reply With Quote
View Public Profile
 
Reply     « Reply to adding value to the .Text
 

Thread Tools Search this Thread
Search this Thread:

Advanced Search

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 Off
Pingbacks are Off
Refbacks are Off





   
RSS Feed  Feeds: RSS   JS   XML
RSS Feed  Feeds for this forum: RSS   JS   XML



Page generated in 0.22842 seconds with 12 queries