Maybe you should replace
Me.txtHoursWorked.Text = HoursWorked
Me.txtHourlyRate.Text = HourlyRate
with
HoursWorked = CDbl(Me.txtHoursWorked.Text)
HourlyRate = CDbl(Me.txtHourlyRate.Text)
This browser is no longer supported.
Upgrade to Microsoft Edge to take advantage of the latest features, security updates, and technical support.
I'm doing code in computer class and we're working on exercises. This exercise is called Payroll and I'm having trouble with it. Every time I try to test, I press the "Pay" button and the numbers reset. Can someone look at my code and help me? I know I did something wrong.
Public Class Form1
Private Sub btnPay_Click(sender As Object, e As EventArgs) Handles btnPay.Click
Dim HoursWorked As Double
Dim HourlyRate As Double
Dim Pay As Double
Dim OvertimeRate As Double
Me.txtHoursWorked.Text = HoursWorked
Me.txtHourlyRate.Text = HourlyRate
If HoursWorked <= 40 Then
Pay = HoursWorked * HourlyRate
Else
OvertimeRate = HourlyRate * 1.5
Pay = (HoursWorked - 40) * 10 * 1.5
End If
If radNo.Checked Then
Pay = Pay * 0.18
Else
MessageBox.Show("No Taxes Deducted")
End If
Me.lblAnswer.Text = "$" & Pay
End Sub
End Class
Maybe you should replace
Me.txtHoursWorked.Text = HoursWorked
Me.txtHourlyRate.Text = HourlyRate
with
HoursWorked = CDbl(Me.txtHoursWorked.Text)
HourlyRate = CDbl(Me.txtHourlyRate.Text)