Private Sub Button1_Click(ByVal sender As System.Object, ByVal e As System.EventArgs) Handles Button1.Click
Dim time1 As String = "123.12"
Dim time2 As String = "123.56"
Dim time3 As String = "000.12"
Dim time4 As String = "000.12"
Dim time5 As String = "000.13"
Dim total As String = ""
total = AddTime(time1, time2)
'total = AddTime(total, time3)
'total = AddTime(total, time4)
'total = AddTime(total, time5)
Me.TextBox3.Text = total
End Sub
Public Function AddTime(ByVal CurrentValue As String, ByVal PreviousValue As String) As String
If Not CurrentValue.Contains(".") Then
CurrentValue = CurrentValue + ".00"
End If
Dim temp As String = CurrentValue
Dim temp1() As String = temp.Split(".")
Dim temp1_Integer As String = temp1(0)
Dim temp1_Decimal As String = "0." + temp1(1)
Dim temp2() As String = PreviousValue.Split(".")
Dim temp2_Integer As String = temp2(0)
Dim temp2_Decimal As String = "0." + temp2(1)
Dim total_Integer As Integer = Integer.Parse(temp1_Integer) + Integer.Parse(temp2_Integer)
Dim total_2Decimal As Single = Format(Single.Parse(temp1_Decimal) + Single.Parse(temp2_Decimal), "0.00")
Dim total As String = ""
If total_2Decimal >= 0.6 Then
total = (total_Integer + 1) + Format((total_2Decimal - 0.6), "0.00")
Else
total = total_Integer + Format(total_2Decimal, "0.00")
End If
total = Format(Single.Parse(total), "000.00").ToString()
Return total
End Function