Hello,
The form i am doing takes from the user the item price, then it will calcuate the subtotal, tax, shipping, and total when the button is clicked. How can i update it so if the user adds another item it will update the subtotal, tax, and total when the button is clicked.

Private Sub btnCalc_Click(ByVal sender As System.Object, ByVal e As System.EventArgs) Handles btnCalc.Click
        
        Dim dblItem As Double
        Dim dblSub As Double
        Dim dblTax As Double
        Dim intShipping As Integer
        Dim dblTotal As Double
        Dim dblnewSub As Double
        Dim dblnewTax As Double
        Dim dblnewtotal As Double

        Double.TryParse(txtItem.Text, dblItem)

        dblSub = dblItem + dblSub

            lblSub.Text = Convert.ToString(dblSub)

            dblTax = dblSub * 0.03
            lblTax.Text = Convert.ToString(dblTax)

            intShipping = "15.00"
            lblShipping.Text = Convert.ToString(intShipping)

            dblTotal = dblSub + dblTax + intShipping
            lblTotal.Text = Convert.ToString(dblTotal)

            If dblTotal >= 100 Then
                intShipping = "0.00"
                lblShipping.Text = Convert.ToString(intShipping)
        ElseIf dblTotal < 100 Then
            intShipping = "15.00"
            lblShipping.Text = Convert.ToString(intShipping)
            End If

Calculate the new values for subtotal, tax, and total and put them in whatever control displays the values txtSubtotal.text = subtotal or lblTax.caption = tax

Edited 4 Years Ago by WaltP: n/a

That just multiplies the first input by two. How can it add new items inputed from the user in the textbox to the labels? So lets say i put in 35, it will show subtotal of 35, tax of 1.05, shipping 15, and total of 51.05. Now if i put in another number like 40 I would want it to add it to the subtotal, tax, and total of the first.

Private Sub btnCalc_Click(ByVal sender As System.Object, ByVal e As System.EventArgs) Handles btnCalc.Click
        
        Dim dblItem As Double
        Dim dblSub As Double
        Dim dblTax As Double
        Dim intShipping As Integer
        Dim dblTotal As Double
        Dim dblnewSub As Double
        Dim dblnewTax As Double
        Dim dblnewtotal As Double

        Double.TryParse(txtItem.Text, dblItem)

        dblSub = dblItem + dblSub



            dblTax = dblSub * 0.03
            lblTax.Text = Convert.ToString(dblTax)

            intShipping = "15.00"
            lblShipping.Text = Convert.ToString(intShipping)

            dblTotal = dblSub + dblTax + intShipping
            lblTotal.Text = Convert.ToString(dblTotal)

            If dblTotal >= 100 Then
                intShipping = "0.00"
                lblShipping.Text = Convert.ToString(intShipping)
        ElseIf dblTotal < 100 Then
            intShipping = "15.00"
            lblShipping.Text = Convert.ToString(intShipping)
            End If

        dblnewSub = dblItem + dblSub
        lblSub.Text = Convert.ToString(dblnewSub)

        dblnewTax = dblnewSub * 0.03
        lblTax.Text = Convert.ToString(dblnewTax)

        dblnewtotal = dblnewSub + dblnewTax + dblTotal
        lblTotal.Text = Convert.ToString(dblnewtotal)


    End Sub

We don't bump here.

The reason I haven't answered is your comments were nonsense based on my previous post:

That just multiplies the first input by two.

And your following question makes no sense for anyone with 2nd grade math:

How can it add new items inputed from the user in the textbox to the labels? So lets say i put in 35, it will show subtotal of 35, tax of 1.05, shipping 15, and total of 51.05. Now if i put in another number like 40 I would want it to add it to the subtotal, tax, and total of the first.

Use the + sign somewhere in your code to add the new values to the old values.

Hi sorry about the 'bump' and the misinformation of the last question. What i am trying to say is how can i have the button's click event keep on adding to the total when the user types in the textbox?

And I don't understand what your problem is.

You have all the values accessible.
You know how to convert a control's text field into a value.
You know how to add two values.
You know how to load a value into a control's text field.

Clearly you are having a specific problem that your general description does not address.

This question has already been answered. Start a new discussion instead.