I am relatively new to coding. I'm trying to figure out why my hours per day aren't converting to numbers that are then added together. Instead they are just taking those strings and writing them as strings and making a huge number.
For example: If I worked 8 hours per day M-F, it displays 88888 instead of 40 (40 hours total for the week). I did convert the strings to a double and then added them together.
Any help is appreciated. I have no teachers to ask on the weekend.
Public Class Form1
Private Sub btnCalc_Click(sender As Object, e As EventArgs) Handles btnCalc.Click
' Get file
Dim srdFile As System.IO.StreamReader
srdFile = New System.IO.StreamReader("payroll.txt")
' Declarations
Dim strLine, strRecord() As String
Dim strFirst As String
Dim strLast As String
Dim strPayRate As String
Dim strMon As String
Dim strTues As String
Dim strWed As String
Dim strThurs As String
Dim strFri As String
Dim dblTotalHours As Double
Dim dblTotalPay As Double
Dim dblGrandTotalPay As Double
Do Until srdFile.Peek = -1
' Read
strLine = srdFile.ReadLine
strRecord = strLine.Split(",")
strFirst = strRecord(0)
strLast = strRecord(1)
strPayRate = Convert.ToDouble(strRecord(2))
strMon = Convert.ToDouble(strRecord(3))
strTues = Convert.ToDouble(strRecord(4))
strWed = Convert.ToDouble(strRecord(5))
strThurs = Convert.ToDouble(strRecord(6))
strFri = Convert.ToDouble(strRecord(7))
' Processing
dblTotalHours = strMon + strTues + strWed + strThurs + strFri
dblTotalPay = dblTotalHours * strPayRate
dblGrandTotalPay += dblTotalPay
' Output
rtbOut.AppendText(strFirst & " " & strLast & ControlChars.Tab & "rate: $" & strPayRate.ToString & ControlChars.Tab & "hours: " & dblTotalHours.ToString("n") & ControlChars.Tab & "pay: " &
dblTotalPay.ToString("c") & vbNewLine & "Total Pay: " & dblGrandTotalPay.ToString("c") & vbNewLine)
Loop
End Sub
End Class