I'm a student doin an introductory course in Visual Basic .Net and i'm having trouble with a lab assignment.
this is what i'm doin and using h = 50 and w = 10 it should return 550 but instead it returns 3250 so obviously i'm doin sumpin wrong i just can't figure out what, it shouldn't be the calculation as when i done it on paper it worked out. any help would really be appreciated.
Visual Basic:
Private Sub btnDisplay_Click(ByVal sender As System.Object, ByVal e As System.EventArgs) Handles btnDisplay.Click
Dim fmtStr As String = "{0,-15} {1,20} {2,15}"
Dim sin, week As String
Dim hours, wages As Double
lstDisplay.Items.Add(String.Format(fmtStr, "S.I.N.", "Week Ending", "Gross Pay"))
lstDisplay.Items.Add("")
GetData(sin, week, hours, wages)
DisplayGross(fmtStr, sin, week, hours, wages)
End Sub
Sub GetData(ByRef sinNumber As String, ByRef weekEnd As String, ByRef hoursWork As Double, ByRef amountPaid As Double)
sinNumber = txtSIN.Text
weekEnd = txtWeek.Text
hoursWork = CDbl(txtHours.Text)
amountPaid = CDbl(txtHours.Text)
End Sub
Sub DisplayGross(ByVal fmtStr As String, ByVal Dsin As String, ByVal Dweek As String, ByVal Dhours As Double, ByVal Dwages As Double)
lstDisplay.Items.Add(String.Format(fmtStr, Dsin, Dweek, CalcGross(Dhours, Dwages)))
End Sub
Function CalcGross(ByVal h As Double, ByVal w As Double) As Double
If h > 40 Then
Return (h - 40) * (1.5 * w) + (h * w)
Else
Return h * w
End If
End Function