Public Class Form1
'In the following line I declare a string for the total gross pay. I will be adding to this value through a loop statement.
Dim gpt As Double
Private Sub btnCalc_Click(ByVal sender As System.Object, ByVal e As System.EventArgs) Handles btnCalc.Click
Dim a As String = "Employee", b As String = "Hourly Rate", c As String = "Hours Worked", d As String = "Gross Pay"
Dim fmtStr As String = "{0,-12}{1,16:C1}{2,20}{3,20:C2}"
Dim name As String, hr As Double, hw As Double, gp As Double, sr As IO.StreamReader = IO.File.OpenText("data.txt")
Dim hrStr As String = "", hwStr As String = "", gpStr As String = ""
lstResults.Items.Clear()
lstResults.Items.Add("Payroll Report for week ending 11/17/06")
lstResults.Items.Add("")
lstResults.Items.Add(String.Format(fmtStr, a, b, c, d))
lstResults.Items.Add("")
Do While sr.Peek <> -1
name = sr.ReadLine
hr = CDbl(sr.ReadLine)
hw = CDbl(sr.ReadLine)
If (hw > 40) Then
gp = (((hw - 40) * 1.5) + (hw * hr))
Else
gp = hr * hw
End If
gpt += gp
hrStr = CStr(hr)
hwStr = CStr(hw)
gpStr = CStr(gp)
lstResults.Items.Add(String.Format(fmtStr, name, CStr(hr), CStr(hw), CStr(gp)))
lstResults.Items.Add("")
lstResults.Items.Add(String.Format(fmtStr, "", "", "", CStr(gpt)))
Loop
End Sub
End Class