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.
Answer a question in the forums and earn +20 SHARP for every answer.
See unanswered questions
DevSocialUpcoming · 3rd editionAI Agents ConferenceDec 1–3, 2026Live onlineFree to attend4days leftRegister
VulpesRank #55 · 29.2K reputationPosted Oct 4, 2014, 1:13 PM EDT
Note that if any number entered is invalid (say ab or 1,2), it will be treated as zero:
William Lee17 reputationPosted Oct 4, 2014, 1:21 PM EDT
VulpesRank #55 · 29.2K reputationPosted Oct 4, 2014, 1:28 PM EDT
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 Lee17 reputationPosted Oct 4, 2014, 1:32 PM EDT
VulpesRank #55 · 29.2K reputationPosted Oct 4, 2014, 1:39 PM EDT
}
William Lee17 reputationPosted Oct 4, 2014, 1:49 PM EDT
VulpesRank #55 · 29.2K reputationPosted Oct 4, 2014, 2:00 PM EDT
Try this version:
William Lee17 reputationPosted Oct 4, 2014, 2:04 PM EDT
VulpesRank #55 · 29.2K reputationPosted Oct 4, 2014, 2:09 PM EDT
total += subTotal;
and not:
total = subTotal;
William Lee17 reputationPosted Oct 4, 2014, 2:13 PM EDT
VulpesRank #55 · 29.2K reputationPosted Oct 4, 2014, 2:36 PM EDT
William Lee17 reputationPosted Oct 4, 2014, 2:48 PM EDT
William Lee17 reputationPosted Oct 4, 2014, 2:58 PM EDT
VulpesRank #55 · 29.2K reputationPosted Oct 4, 2014, 3:36 PM EDT
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 Lee17 reputationPosted Oct 4, 2014, 3:37 PM EDT