0
Public Class Form1

    Dim salesAmt As Double
    Const stateRate As Double = 0.025
    Const countyRate As Double = 0.005
    Const cityRate As Double = 0.0025
    Dim stateTax As Double
    Dim countyTax As Double
    Dim cityTax As Double



    Public Sub Label1_Click(sender As Object, e As EventArgs) Handles entryLabel.Click
        salesAmt = Convert.ToDouble(salesAmtTextBox.Text)

    End Sub

    Public Sub subButton_Click(sender As Object, e As EventArgs) Handles subButton.Click

        stateTax = stateRate * salesAmt
        countyTax = countyRate * salesAmt
        cityTax = cityRate * salesAmt

        stateLabel.Text = stateTax.ToString("C2")
        countyLabel.Text = countyTax.ToString("C2")
        cityLabel.Text = cityTax.ToString("C2")
    End Sub
End Class

I'm meant to make a small application that displays tax rates for state/county/city, has a box to input the quarterly sales amount, and a submit button to calculate that amount and display all three tax values. Every time I hit submit I'm getting $0.00 in all the text boxes, I'm not sure what I'm doing wrong.

1 Answer 1

1

I think here is the problem.. You have to make it clear. Besides, you can remove the Label1.Click. It is no function if you don't click it.

Public Sub subButton_Click(sender As Object, e As EventArgs) Handles subButton.Click

stateTax = stateRate * salesAmtTextBox.Text
countyTax = countyRate * salesAmtTextBox.Text
cityTax = cityRate * salesAmtTextBox.Text

stateLabel.Text = stateTax.ToString("C2")
countyLabel.Text = countyTax.ToString("C2")
cityLabel.Text = cityTax.ToString("C2")
End Sub
Sign up to request clarification or add additional context in comments.

2 Comments

I just realized my mistake, thanks! Yeah, idk why that was there, I think I just wasn't reading it properly and just stuck it in the place I thought I was working in (Gosh I feel stupid)
That's great. You can also declare it in the subButton_Click . Example: Dim salesAmt = salesAmtTextBox.Text. Click 'tick' on the left corner if the question is answered.

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service and acknowledge you have read our privacy policy.

Start asking to get answers

Find the answer to your question by asking.

Ask question

Explore related questions

See similar questions with these tags.