I am new to Visual Basic I'm a student and im working on a payroll calculator program I got it to where it will display user input now i have to get it to calculate pay based on which radio button is selected im doing this one at a time the Trainee button is 10.00 for regular hours and 15.00 for overtime hours and I have to use format currency as well here is what I have code wise any points in the right direction will be greatly welcomed Thank You.

Option Strict On
Public Class PayrollCalculator

    Dim intRegularPay As Integer
    Dim intOtPay As Integer
    Dim strEmployeeType As String
    Dim strTrainee As String
    Dim strRegular As String
    Dim strManager As String
    Dim intHoursWorked As Integer

    'Sets Employee Type to button selected
    Private Sub gbEmployeeType_Enter(ByVal sender As System.Object, ByVal e As System.EventArgs) Handles gbEmployeeType.Enter
        If (RadioButton1.Checked = True) Then
            strEmployeeType = strTrainee
        ElseIf (RadioButton2.Checked = True) Then
            strEmployeeType = strRegular
        ElseIf (RadioButton3.Checked = True) Then
            strEmployeeType = strManager
        End If

        If (strEmployeeType = strTrainee) Then
            intRegularPay = 10
        ElseIf (strEmployeeType = strRegular) Then
            intRegularPay = 15
        ElseIf (strEmployeeType = strManager) Then
            intRegularPay = 20
        End If

    End Sub

    'Displays all input information calculates pay displays result
    Private Sub btnCalculate_Click(ByVal sender As System.Object, ByVal e As System.EventArgs) Handles btnCalculate.Click
        txtEmployeeName.Text = txtEmployee.Text 'displays employee name 
        txtRegularHours.Text = CStr(txtHoursWorked.Text) 'displays regular hours worked
        txtOtHours.Text = CStr(txtOvertime.Text) 'displays overtime hours worked

        txtHoursWorked.Text = CStr(intHoursWorked)
        txtRegularPay.Text = CStr((intHoursWorked * intRegularPay))

    End Sub

    Private Sub btnClear_Click(ByVal sender As System.Object, ByVal e As System.EventArgs) Handles btnClear.Click

    End Sub

    Private Sub btnExit_Click(ByVal sender As System.Object, ByVal e As System.EventArgs) Handles btnExit.Click
    End Sub

End Class
6 Years
Discussion Span
Last Post by codeorder

Check out this link about formatting to currency.

Overlooking your code, I would set both, the EmplyeeType and RegularPay in the same hit.

If RadioButton1.Checked = True Then
            strEmployeeType = strTrainee : intRegularPay = 10
        ElseIf RadioButton2.Checked = True Then
            strEmployeeType = strRegular : intRegularPay = 15
        ElseIf RadioButton3.Checked = True Then
            strEmployeeType = strManager : intRegularPay = 20
        End If

Edited by codeorder: n/a

This topic has been dead for over six months. Start a new discussion instead.
Have something to contribute to this discussion? Please be thoughtful, detailed and courteous, and be sure to adhere to our posting rules.