0

Hi guys i'm writing a script (Visual Studios 10 express) to simulate a restaurant cash register. I am having problems gettin my values from each selected item to add up and display in the subtotal label. As of now i have it to where when i select a quantity of an item the totoal amount for those items display in a :value: label and in the subtotoal label. But the problem occurs when i select another item, instead of it adding the total of the first item and second selection, it only replaces the numbers. if anyone has any ideas or simular script your help will be greatly appreciated
Thanks in advance,

1
Contributor
2
Replies
3
Views
5 Years
Discussion Span
Last Post by jetlife76
0

here's the bit of code that handles the selected index change events, there are 4 dropdown listd for Burgers, Fries, Drinks and Pies. when the number of each item is selected, the total price for whatever qty of each is displayed in labels and then to the subtotal label where the order's total before tax is calculated

Protected Sub ddlBurgerQty_SelectedIndexChanged(sender As Object, e As System.EventArgs) Handles ddlBurgerQty.SelectedIndexChanged

        Dim qty As Integer = ddlBurgerQty.SelectedIndex
        Dim price As Double
        Double.TryParse(lblBurgerPrice.Text, price)
        dblBurgerQty = qty * price
        lblBurgerValue.Text = dblBurgerQty.ToString("###.00")
        dblSubtotal = dblBurgerQty + dblFriesQty + dblDrinksQty0 + dblPieQty



        If qty < 1 Then lblBurgerValue.Text = ""
        If qty > 1 Then lblBurgerValue.Text = dblBurgerQty.ToString("####.00")
        lblSubtotal.Text = dblSubtotal.ToString("###.00")

    End Sub


    Protected Sub ddlFriesQty_SelectedIndexChanged(sender As Object, e As System.EventArgs) Handles ddlFriesQty.SelectedIndexChanged
        Dim qty As Integer = ddlFriesQty.SelectedIndex
        Dim price As Double
        Dim Subtotals As Double
        Double.TryParse(lblFriesPrice.Text, price)
        Double.TryParse(lblSubtotal.Text, Subtotals)

        dblFriesQty = qty * price
        lblFriesValue.Text = dblFriesQty.ToString("###.00")
        dblSubtotal = dblBurgerQty + dblFriesQty + dblDrinksQty0 + dblPieQty


        If qty < 1 Then lblFriesValue.Text = ""
        If qty > 1 Then lblFriesValue.Text = dblFriesQty.ToString("####.00")
        lblSubtotal.Text = dblSubtotal.ToString("###.00")

    End Sub


    Protected Sub ddlDrinksQty0_SelectedIndexChanged(sender As Object, e As System.EventArgs) Handles ddlDrinksQty0.SelectedIndexChanged
        Dim qty As Integer = ddlDrinksQty0.SelectedIndex
        Dim price As Double
        ' Dim amount As Double
        Double.TryParse(lblDrinksPrice0.Text, price)
        'Double.TryParse(lblSubtotal.Text, amount)

        dblDrinksQty0 = qty * price
        lblDrinkValue0.Text = dblDrinksQty0.ToString("###.00")
        dblSubtotal = dblBurgerQty + dblFriesQty + dblDrinksQty0 + dblPieQty


        If qty < 1 Then lblDrinkValue0.Text = ""
        If qty > 1 Then lblDrinksPrice0.Text = dblDrinksQty0.ToString("####.00")
        lblSubtotal.Text = dblSubtotal.ToString("###.00")


    End Sub


    Protected Sub ddlPieQty_SelectedIndexChanged(sender As Object, e As System.EventArgs) Handles ddlPieQty.SelectedIndexChanged
        Dim qty As Integer = ddlPieQty.SelectedIndex
        Dim price As Double
        Double.TryParse(lblPiePrice.Text, price)
        dblPieQty = qty * price

        dblSubtotal = dblBurgerQty + dblFriesQty + dblDrinksQty0 + dblPieQty

        If qty < 1 Then lblPieValue.Text = ""
        If qty > 1 Then lblPieValue.Text = dblPieQty.ToString("####.00")
        lblSubtotal.Text = dblSubtotal.ToString("###.00")

    End Sub
0

Ok i found out what i was missing, i only needed to Call Calculations() in order to get the reults to display, hope this helps someone else

This topic has been dead for over six months. Start a new discussion instead.
Have something to contribute to this discussion? Please be thoughtful, detailed and courteous, and be sure to adhere to our posting rules.