CalculateSolution

  • Private Sub btnCalculate_Click(sender As System.Object, e As System.EventArgs) Handles btnCalculate.Click

    'This button calculates the money you earned in the week.

    'This button is executed when the user clicks the button or the enter key is pushed.

    'declare variables

    Dim strHours As String

    Dim decHours As Decimal

    Dim strRate As String

    Dim decRate As Decimal

    Dim decGross As Decimal

    Dim decTax As Decimal

    Dim decNet As Decimal

    strHours = Me.txtHours.Text 'get the value from the form

    decHours = Convert.ToDecimal(strHours) 'convert from string to decimal

    strRate = Me.txtRate.Text 'get the value from the form

    decRate = Convert.ToDecimal(strRate) 'convert from string to decimal

    'calculate

    decGross = decHours * decRate

    decTax = decGross * _cdecTaxRate

    decNet = decGross - decTax

    'display and format as currency

    Me.lblGross.Text = decGross.ToString("C")

    Me.lblTax.Text = decTax.ToString("C")

    Me.lblNet.Text = decNet.ToString("C")

    End Sub