r/visualbasic • u/Lord_Ewok • Nov 02 '18
Using If Else to Calcuate Wages .
Hey guys so am making a wage Calc and i am using If Else to perform the calculations if Hours are above 0 make the calc or show a error message if they are 0. Although it doesnt the show error message when hours are 0
Public Class frmGross
Private Sub btnCalcuate_Click(sender As Object, e As EventArgs) Handles btnCalcuate.Click
Dim decHours As Decimal
Dim decHourlyWage As Decimal
Dim decTotalPay As Decimal
decHours = txtHours.Text
decHourlyWage = txtHourlyWage.Text
decTotalPay = decHours * decHourlyWage
LblTotalPay.Text = decTotalPay
If decHours >= 0 Then
decHours = txtHours.Text
decHourlyWage = txtHourlyWage.Text
decTotalPay = decHours * decHourlyWage
LblTotalPay.Text = decTotalPay.ToString("C2")
Else
LblTotalPay.Text = "Error"
End If
End Sub
Private Sub BtnExit_Click(sender As Object, e As EventArgs) Handles BtnExit.Click
Me.Close()
End SubEnd Class
