VB help with adding up value! (VB form)

Associate
Joined
23 Mar 2010
Posts
730
ok so i basically need the prgram to add up the money each time the button is pressed:

e.g.

a vending machine with buttons (20p, 50p, £1) ..for like inserting money
i used a 'label' for displaying how much is inserted

everytime i click the button, i want it to add to the total of the 'label'

how would i do this?
 
Public Total As Integer = 0

Just set each button to add a specific amount as below:

Private Sub Button1_Click_3(ByVal sender As System.Object, ByVal e As System.EventArgs) Handles Button1.Click
Total += 50
End Sub
 
ok so i basically need the prgram to add up the money each time the button is pressed:

e.g.

a vending machine with buttons (20p, 50p, £1) ..for like inserting money
i used a 'label' for displaying how much is inserted

everytime i click the button, i want it to add to the total of the 'label'

how would i do this?

You do it by looking at your lecture notes and doing your own home\course work ;)

If you have a specific bug or problem you need help with the by all means ask, but adding values together is beginners 2nd or 3rd lesson stuff.
 
ok so i basically need the prgram to add up the money each time the button is pressed:

e.g.

a vending machine with buttons (20p, 50p, £1) ..for like inserting money
i used a 'label' for displaying how much is inserted

everytime i click the button, i want it to add to the total of the 'label'

how would i do this?

As namnoc suggested:

Have a class (or module) based variable which holds the total and for each button you have (20p/50p/£1 etc), add that to the value of the "total" variable. You can output this to a label/textbox as you run through the code too.
 
Back
Top Bottom