473,406 Members | 2,710 Online
Bytes | Software Development & Data Engineering Community
Post Job

Home Posts Topics Members FAQ

Join Bytes to post your question to a community of 473,406 software developers and data experts.

-HELP- sum of 2 textboxs and then getting the total in the last textbox

I am trying to get 2 numbers from 2 textboxs and get a return sum in the third textbox. the strange thing is that i got it to work with this code that i am going to provide on the last app i worked on, now on the new app i am on it doesnt work at all.. I am not getting any Errors, just shows a zero when i calculate to the sum of the total textbox.

Expand|Select|Wrap|Line Numbers
  1. int sum1 = 0;
  2.             int sum2 = 0;
  3.             int result = 0;
  4.  
  5.             if (int.TryParse(txtPrice.Text, out sum1) & int.TryParse(txtQuantity.Text, out sum2))
  6.                 result = sum1 * sum2;
  7.             txtSubTotal.Text = result.ToString();
  8.  
Oct 3 '14 #1
11 1509
Rabbit
12,516 Expert Mod 8TB
In what way does it not work? Are you getting an error message? What is the error message?

Also, in your code, you are multiplying, not adding.
Oct 3 '14 #2
Not getting an error messsage at all.. it just shows a zero in the third sum total textbox
Oct 3 '14 #3
Rabbit
12,516 Expert Mod 8TB
I would check the values of all the variables along each step of the code to make sure it's populating correctly.
Oct 3 '14 #4
I dont see any difference, everything seems to be right but it isnt doing what it suppose to do, examples would be nice :)
Oct 3 '14 #5
Rabbit
12,516 Expert Mod 8TB
So you're saying the debugger shows the correct value is the variable result?
Oct 4 '14 #6
thats correct, no errors, but i get a zero on the total.
Oct 4 '14 #7
Rabbit
12,516 Expert Mod 8TB
There's some sort of miscommunication happening. With the code you posted and the description of what you want, it's very unlikely that the value in the variable result is correct.

You said you wanted to add 2 numbers. But your code shows that you are multiplying. So unless your test numbers are 2 and 2, or something like that, there's no way your result variable should hold the correct value.
Oct 4 '14 #8
What miscommunication are you talking about.. adding two numbers was misdirected, i wanted multiply those numbers to get the sum of the total. Is there another ways to do this, then this type of code...
Oct 4 '14 #9
ok I wrote another program using the same code and it worked, would it be something in the program on the inventory system i am working on causing issues or to much code under one button.
Oct 4 '14 #10
ok what i had to do is add another button to the inventory system and it seem to work out... i had to much code under the Add button, when I created the Sum button everything stop freaking out.
Oct 4 '14 #11
Rabbit
12,516 Expert Mod 8TB
I'm not sure I understand what you just said but it sounds like you fixed your problem?
Oct 4 '14 #12

Sign in to post your reply or Sign up for a free account.

Similar topics

7
by: RC | last post by:
I have a form with five text boxes on it. The format for all the boxes is set as General Number. In four of the boxes the user can enter a number, the fifth box totals up the values in the other...
11
by: Jim H | last post by:
I am trying to go through my Outlook (2003) address book. The code goes through the Items list and prints all the last names but after it hits 114 (out or 126 contacts) I get a "sepcified cast is...
1
by: MattB | last post by:
OK, never mind my last post. It was easy enough to refer to the table the repeater is bound to, but I made a big, incorrect assumption in that post. In my last post I thought I was successfully...
5
by: velu | last post by:
Problem in getting value from textbox & radiobuttonlist to a valuable inside a datagid. I want to insert a record into a table thru datagrid. Here is the code (see below) Private Sub...
2
by: Booster | last post by:
Hi, Could someone help me I have a form where i chose the customer so i also have on this form a datagrid with with the invoices of this customer i have shosen Now: I want to have the sum a...
0
by: jimmy6509 | last post by:
Hello all, asp.net 2.0, VB. Have a simple question that I hope someone can help me with. gridview -> queries for a filtered recordset, example purchase orders attributed to a specific...
0
by: mra | last post by:
hi every body i need a help for finding page total in crystal report 7. please give me solution, ery urgent. thanks in advance
1
by: chadw | last post by:
Not sure what I am missing sure its probably something very simple, I need something to get my entered text out of the textbox and entered into a database currently the code looks like this. ...
1
by: indosmoke | last post by:
Hey all, I'm trying to get a total average of the daily average. Below is my query for getting the daily average: SELECT DailyAverage=AVG(T.Photo_Reading) ,date=s.H_date FROM T...
3
by: mrhua | last post by:
i have 50 column and i want to sum one by one , the total will show in the textbox that mean total of each column will show in each textbox , please take my hand to do it , because i m newbie ...
0
by: Charles Arthur | last post by:
How do i turn on java script on a villaon, callus and itel keypad mobile phone
0
by: emmanuelkatto | last post by:
Hi All, I am Emmanuel katto from Uganda. I want to ask what challenges you've faced while migrating a website to cloud. Please let me know. Thanks! Emmanuel
1
by: nemocccc | last post by:
hello, everyone, I want to develop a software for my android phone for daily needs, any suggestions?
1
by: Sonnysonu | last post by:
This is the data of csv file 1 2 3 1 2 3 1 2 3 1 2 3 2 3 2 3 3 the lengths should be different i have to store the data by column-wise with in the specific length. suppose the i have to...
0
by: Hystou | last post by:
Most computers default to English, but sometimes we require a different language, especially when relocating. Forgot to request a specific language before your computer shipped? No problem! You can...
0
Oralloy
by: Oralloy | last post by:
Hello folks, I am unable to find appropriate documentation on the type promotion of bit-fields when using the generalised comparison operator "<=>". The problem is that using the GNU compilers,...
0
jinu1996
by: jinu1996 | last post by:
In today's digital age, having a compelling online presence is paramount for businesses aiming to thrive in a competitive landscape. At the heart of this digital strategy lies an intricately woven...
0
by: Hystou | last post by:
Overview: Windows 11 and 10 have less user interface control over operating system update behaviour than previous versions of Windows. In Windows 11 and 10, there is no way to turn off the Windows...
0
isladogs
by: isladogs | last post by:
The next Access Europe User Group meeting will be on Wednesday 1 May 2024 starting at 18:00 UK time (6PM UTC+1) and finishing by 19:30 (7.30PM). In this session, we are pleased to welcome a new...

By using Bytes.com and it's services, you agree to our Privacy Policy and Terms of Use.

To disable or enable advertisements and analytics tracking please visit the manage ads & tracking page.