รายละเอียดของการตอบ ::
ประกาศไปแล้วครับ
Dim myCompareTime As DateTime = DateTime.Parse("00:15:00")
Dim iCount As Integer = 0
Dim stringTotalTime As String = String.Empty
Dim myDgvTime As TimeSpan = New TimeSpan(0, 0, 0)
Dim stringDetail As String = String.Empty
Dim stringOt As String = String.Empty
Dim allItemCount As Integer = 0
For iRow As Integer = 0 To dgvTimework.Rows.Count - 1
If Not IsDBNull(dgvTimework.Rows(iRow).Cells("ot").Value) And Not IsDBNull(dgvTimework.Rows(iRow).Cells("ot").Value) Then
allItemCount += 1
Dim dgvTimeString = CType(dgvTimework.Rows(iRow).Cells("ot").Value, String)
stringDetail &= CType(dgvTimework.Rows(iRow).Cells("ot").Value, String) & vbNewLine
Dim dgvTime As DateTime
Dim tspTotal As New TimeSpan 'ลองเพิ่มโค้ดนี้นะครับ
If DateTime.TryParse(dgvTimeString, dgvTime) Then
If dgvTime > myCompareTime Then
stringOt &= dgvTimeString & vbNewLine
Dim eachRow As TimeSpan = New TimeSpan(Hour(dgvTime), Minute(dgvTime), Second(dgvTime))
tspTotal += eachRow 'ลองเปลี่ยนเป็นโค้ดนี้นะครับ
iCount += 1
End If
Else
MsgBox("Error: Unable to parse " & dgvTimeString)
End If
End If
Next iRow
Dim iTotalDay_OT As Integer = tspTotal.TotalDay 'เก็บจำนวนวันที่ทำโอที
Dim iHour_OT As Integer = tspTotal.Hour 'เก็บจำนวนชั่วโมง
Dim iMinute_OT As Integer = tspTotal.Minute 'เก็บจำนวนนาที
txtCountot.Text = iTotalDay_OT.ToString
txtOt.Text = iHour_OT.ToString("00") + ":" + iMinute_OT.ToString("00")