0

''' <summary>
''' FUNCTION TO CALCULATE SUM OF TWO TIME VALUES
''' PASS TWO DATE VALUES AS STRING
''' </summary>
Function GetTimeSum(ByVal dt1 As String, ByVal dt2 As String) As String
Dim ReturnStr As String = ""

If dt1 = "" And dt2 <> "" Then
Return dt2
ElseIf dt1 <> "" And dt2 = "" Then
Return dt1
End If

Dim Min1 As Integer = dt1.Substring(dt1.IndexOf(":") + 1) 'MINITUE OF FIRST DATE
Dim Min2 As Integer = dt2.Substring(dt2.IndexOf(":") + 1) 'MINIUTE OF SECOND DATE

Dim Hour1 As Integer = dt1.Substring(0, dt1.IndexOf(":")) 'HOURS OF FIRST DATE
Dim Hour2 As Integer = dt2.Substring(0, dt2.IndexOf(":")) 'HOURS OF SECOND DATE

Dim TotalHour As Integer = Hour1 'TOTAL HOURS
Dim TotalMin As Integer = 0 'TOTAL MINUTES

Dim ExtraMin As Integer = 0

If Min1 + Min2 > 60 Then
ExtraMin = 60 - Min1
TotalHour += 1
TotalMin = Min2 - ExtraMin
Else
TotalMin = Min1 + Min2
End If

TotalHour += Hour2

If TotalHour.ToString.Length = 1 Then
TotalHour = "0" & TotalHour
End If
If TotalMin.ToString.Length = 1 Then
TotalMin = "0" & TotalMin
End If

ReturnStr = TotalHour.ToString & ":" & TotalMin.ToString

Return ReturnStr
End Function

Time 
sum
Integer
2
Contributors
1
Reply
3
Views
8 Years
Discussion Span
Last Post by roby22
0

How do i pass two values from to different text boxes to this function?

thanks for input

Have something to contribute to this discussion? Please be thoughtful, detailed and courteous, and be sure to adhere to our posting rules.