The user inputs what they want in the forms. For example, in the snacks the user wants 2 burgers and it will cost 160 each - which is shown in total value.
Total value:
Then, the user changed their mind and decided they want 6 burgers instead of 2. The total value is still 160 when "Place Order" is clicked. I expect that the value will update when the user changes the input. How can I fix this?
(VB.NET)
Public Class Formpreceipt
Dim party = Formrooms.txtparty.Text
Dim partyy As Double
Dim bday = Formrooms.txtbday.Text
Dim bdayy As Double
Dim vip = Formrooms.txtvip.Text
Dim vipp As Double
Dim deluxe = Formrooms.txtdeluxe.Text
Dim deluxee As Double
Dim fries = Formsnacks.txtfries.Text
Dim friess As Double
Dim burger = Formsnacks.txtburger.Text
Dim burgerr As Double
Dim cupcake = Formsnacks.txtcupcake.Text
Dim cupcakee As Double
Dim pizza = Formsnacks.txtpizza.Text
Dim pizzaa As Double
Dim icedtea = Formdrinks.txticedtea.Text
Dim icedteaa As Double
Dim soda = Formdrinks.txtsoda.Text
Dim sodaa As Double
Dim soju = Formdrinks.txtsoju.Text
Dim sojuu As Double
Dim beer = Formdrinks.txtbeer.Text
Dim beerr As Double
Private Sub Formpreceipt_Load(sender As Object, e As EventArgs) Handles MyBase.Load
End Sub
Private Sub Button1_Click(sender As Object, e As EventArgs) Handles btnplaceorder.Click
partyy = party * 200
bdayy = bday * 300
vipp = vip * 400
deluxee = deluxe * 500
friess = fries * 40
burgerr = Val(burger) * 80
cupcakee = cupcake * 35
pizzaa = pizza * 150
icedteaa = icedtea * 20
sodaa = soda * 35
sojuu = soju * 80
beerr = beer * 100
txtotal.Text = "₱" & Format(partyy bdayy vipp deluxee friess burgerr cupcakee pizzaa icedteaa sodaa sojuu beerr)
End Sub
End Class
CodePudding user response:
There is room for improvement on your design, but as suggested by user9938, move the assignments to the Click() event of your button.
Change:
partyy = party * 200
bdayy = bday * 300
vipp = vip * 400
deluxee = deluxe * 500
friess = fries * 40
burgerr = burger * 80
cupcakee = cupcake * 35
pizzaa = pizza * 150
icedteaa = icedtea * 20
sodaa = soda * 35
sojuu = soju * 80
beerr = beer * 100
To:
partyy = Formrooms.txtparty.Text * 200
bdayy = Formrooms.txtbday.Text * 300
vipp = Formrooms.txtvip.Text * 400
deluxee = Formrooms.txtdeluxe.Text * 500
friess = Formsnacks.txtfries.Text * 40
burgerr = Formsnacks.txtburger.Text * 80
cupcakee = Formsnacks.txtcupcake.Text * 35
pizzaa = Formsnacks.txtpizza.Text * 150
icedteaa = Formdrinks.txticedtea.Text * 20
sodaa = Formdrinks.txtsoda.Text * 35
sojuu = Formdrinks.txtsoju.Text * 80
beerr = Formdrinks.txtbeer.Text * 100
CodePudding user response:
If I read your code, in the Button1_Click
you have burgherr = burger * 80
First of all I suggest you to get the Value of variable burger like Val(burger) * 80
after than, in your code I can't see where you update and use the total value... I expect that you have something like TextBoxTotalValue.Text = burgherr.ToString()