VB Tax Calculator

webmast3r

New member
Joined
Oct 25, 2009
Messages
1
Programming Experience
1-3
Hi! Im new to these forums and am just beginning to learn VB. My main area of IT is web development and I have about 2 years of programming experience with XHTML, CSS, and JavaScript. My program is fairly simple, I need to create a Windows Form Application that calculates sales tax when the tax rate is 6.5%. When the Calculate button is clicked, the amount input is multiplied by the rate as a decimal, .065. The result is then displayed in a textbox in a currency format. This result is added to the orginal amount to display in the Total textbox. Im not exactly sure how to take the outputs and display them in the correct textboxes. Here is my code so far:
VB.NET:
Option Explicit On
Option Strict On

Public Class Form1
    Private Sub btnExit_Click_1(ByVal sender As System.Object, ByVal e As System.EventArgs) Handles btnExit.Click

        Me.Close()

    End Sub

    Private Sub btnReset_Click(ByVal sender As System.Object, ByVal e As System.EventArgs) Handles Reset.Click

        txtInput.Text = ""
        lblResult.Text = Nothing

    End Sub

    Private Sub btnCalculate_Click(ByVal sender As System.Object, ByVal e As System.EventArgs) Handles Button1.Click
        Dim decInput As Decimal
        Dim decOutput As Decimal

        decInput = Convert.ToDecimal(txtInput.Text)
        decOutput = decInput * (0.065)
        lblResult.Text = decOutput.ToString

        decOutput = decInput + decOutput
        lblResult.Text = decOutput.ToString

    End Sub

End Class
 
VB.NET:
        decOutput = decInput * (0.065)
        lblResult.Text = decOutput.ToString

        decOutput = decInput + decOutput
        lblResult.Text = decOutput.ToString
You're first assigning the tax amount to the label then before the user can even see it you're assigning the total (the amount plus the tax) to the same label. You probably would want two labels, one for the tax amount and the other for the total.
 
Back
Top