Hello (I have not been here for a long time !) .
I suggest you use a structure ===>> example ===>>
Should always be right.Code:Private Type my_times hours As String minutes As String seconds As String milliseconds As String End Type Private Sub Commandbutton1_Click() Dim time1 As String, time2 As String, milliseconds As Long, my_res As my_times time1 = "13:11:25:400" time2 = "12:11:26:500" milliseconds = to_milliseconds(time1) - to_milliseconds(time2) MsgBox from_milliseconds(milliseconds).hours & ":" & from_milliseconds(milliseconds).minutes & ":" & from_milliseconds(milliseconds).seconds & ":" & from_milliseconds(milliseconds).milliseconds End Sub Public Function to_milliseconds(what As String) As Long toto = Split(what, ":") to_milliseconds = (toto(0) * 3600000) + (toto(1) * 60000) + (toto(2) * 1000) + toto(3) End Function Private Function from_milliseconds(what As Long) As my_times from_milliseconds.hours = Format(what \ 3600000, "00") what = what Mod 360000 from_milliseconds.minutes = Format(what \ 60000, "00") what = what Mod 6000 from_milliseconds.seconds = Format(what \ 1000, "00") from_milliseconds.milliseconds = Format(what Mod 1000, "000") End Function




Reply With Quote