Running Totals

tk.unlimited

Active member
Joined
Apr 2, 2005
Messages
27
Programming Experience
1-3
Hey All
Can someone tell me how to display a running total to be displayed on a Label FROM a listbox? Also i want to include an Order number as well.. which would also be a running total.. Any suggestions on how to code this Order no?

Know im asking too much but also when a button is clicked... I want a window to popup showing statistics.. any suggestions.. THANKS!!

Regards
Tk
 
Last edited:
Your request is very unclear.
tk.unlimited said:
Can someone tell me how to display a running total to be displayed on a Label FROM a listbox?
A running total of what? If you want to display something in a Label you simply assign that something to the Label's Text property. Surely you are asking how to calculate the value and not how to display it.

tk.unlimited said:
Also i want to include an Order number as well.. which would also be a running total.. Any suggestions on how to code this Order no?
I think you must mean that the Order Number will be incremented automatically rather than be a running total. Generally your database will be responsible for incrementing the key for a table.

tk.unlimited said:
Know im asking too much but also when a button is clicked... I want a window to popup showing statistics.. any suggestions..
If you're asking how to create the popup window you would just use a MessageBox. If you're asking how to calculate the statistics you'll need to specify what these statistics are supposed to be.
 
Let me clear it up for ya

Ok i want a running total of the total $ amount in the till... Soo yes the CALCULATION.. I currently calculate each total AFTER i click the calculate button.. HOWEVER i want the program to SUM all of the values that have been calculated..To show a TOTAL for the day.. Is that more clear??

ALSO yes i want the program to increment after each total is processed... Im not using a database as it is a prototupe and im using a text file... Soo a count of each Order processed??? Want to know how to code it..
 
Last edited:
First of all, I would suggest displaying the running total in a read-only TextBox with a descriptive Label, rather than in a Label itself. You can start the day displaying the till contents like so:
VB.NET:
[color=Blue]Dim[/color] tillContents [color=Blue]As Decimal[/color]

[color=Green] 'Retrieve the initial till contents.[/color]

[color=Blue] Me[/color].tillContentsText.Text = FormatCurrency(tillContents)
When you perform a transaction you can add the transaction total to the till contents either via the tillContents variable, assuming you declared it with Form-level scope:
VB.NET:
[color=Blue]Dim[/color] transactionTotal [color=Blue]As Decimal[/color]

[color=Green] 'Retrieve the total of the last transaction.[/color]

tillContents += transactionTotal
[color=Blue] Me[/color].tillContentsText.Text = FormatCurrency(tillContents)
or to the TextBox directly:
VB.NET:
[color=Blue]Dim[/color] transactionTotal [color=Blue]As Decimal[/color]
 
[color=Green]  'Retrieve the total of the last transaction.[/color]
 
[color=Blue] Me[/color].tillContentsText.Text = FormatCurrency([color=Blue]Decimal[/color].Parse([color=Blue]Me[/color].tillContentsText.Text, Globalization.NumberStyles.Currency) + transactionTotal)

As for the Order Number, simply start with an orderNumber variable declared as an Integer or Long and set to 1, then increment it each time you need to:
VB.NET:
[color=Blue]Dim[/color] orderNumber [color=Blue]As Integer[/color] = 0

[color=Green]'Use current order number.
'...

'Increment order number.[/color]
orderNumber += 1

If you need to persist these values across sessions, create a class or structure to contain them and serialise it at the end of each session and deserialise it at the start of each new session.
 
Last edited:
Back
Top