I am new to programming, I have 2 textbox's one is the subtotal and total, when i put in a bunch of numbers in the subtotal, i want it to total up.
thanks
william
Know the answer? Post it — somebody with the same question will find it here.
Sign in to answer this question
It is the same account you read, post and publish with — and you will come straight back to this page.
William LeePosted Oct 4, 2014, 7:37 PM
VulpesPosted Oct 4, 2014, 7:36 PM
If you re-select a line that's already been processed, it will be processed again because the method has no way of knowing what's already been processed.
If you're going to transfer the subtotal to the second column of the ListView, then the method could check whether there's already something in that column and, if there is, just return without doing anything.
William LeePosted Oct 4, 2014, 6:58 PM
William LeePosted Oct 4, 2014, 6:48 PM
VulpesPosted Oct 4, 2014, 6:36 PM
William LeePosted Oct 4, 2014, 6:13 PM
VulpesPosted Oct 4, 2014, 6:09 PM
total += subTotal;
and not:
total = subTotal;
William LeePosted Oct 4, 2014, 6:04 PM
VulpesPosted Oct 4, 2014, 6:00 PM
Try this version:
William LeePosted Oct 4, 2014, 5:49 PM
VulpesPosted Oct 4, 2014, 5:39 PM
}
William LeePosted Oct 4, 2014, 5:32 PM
VulpesPosted Oct 4, 2014, 5:28 PM
For example, if I enter this in the subtotal box:
12 15.3 17 20 25.1
and click the button, the total box (correctly) shows:
89.4
So are you separating the numbers with something else such as a comma?
William LeePosted Oct 4, 2014, 5:21 PM
VulpesPosted Oct 4, 2014, 5:13 PM
Note that if any number entered is invalid (say ab or 1,2), it will be treated as zero: