I can't see the wood for all the trees now....
I am work on a time program, for staff to check in and out.
in a grid i show all the days working and add the total hours work for that day(
GetTotalTime). that means during the
grid Initialize Row i use this:
Private Sub GrdOverViewInitializeRow(sender As Object, e As Infragistics.Win.UltraWinGrid.InitializeRowEventArgs) Handles grdOverView.InitializeRow
StartTime = e.Row.Cells(4).Text.ToString
StartDate = e.Row.Cells(5).Text.ToString
FinishTime = e.Row.Cells(6).Text.ToString
FinishDate = e.Row.Cells(7).Text.ToString
StartTime = String.Format("{0} {1}", StartDate, StartTime)
FinishTime = String.Format("{0} {1}", FinishDate, FinishTime)
WorkTime = GetTotalTime(StartTime, FinishTime)
grdOverView.Text = CalculateTime(WorkTime)
e.Row.Cells(9).Value = WorkTime
End Sub
So fare so good, however during this i use
Calculatetime as below for Grand total:
Friend Function CalculateTime(ByVal calworktime As String) As String
Try
Dim input As String = calworktime
Dim parts = input.Split(":"c)
Dim hours = Int32.Parse(parts(0))
Dim minutes = Int32.Parse(parts(1))
Dim result = New TimeSpan(hours, minutes, 0)
TotalTime = TotalTime.Add(result)
Dim s As String = String.Format("{0}:{1}", TotalTime.TotalHours.ToString("00"), TotalTime.Minutes.ToString("00"))
CalculateTime = String.Format("Total time: {0}", s.ToString)
Return CalculateTime
Catch ex As Exception
MessageBox.Show(ex.Message.ToString)
Return Nothing
End Try
End Function
This is where it goes wrong. if it is just adding whole hours together, no problems.
howere for exsample: 5 hrs + 45 min=6hrs and 45min...where did the extra hour come from?????
WorkTime and TotalTime is declare in a general module.
Any ideas where i am losing the plot...
Thnaks