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,

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

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

Be a part of the DaniWeb community

We're a friendly, industry-focused community of developers, IT pros, digital marketers, and technology enthusiasts meeting, networking, learning, and sharing knowledge.