Android Question Time string 0:00:00 to ms


Licensed User
Longtime User
Hi Erel,
I have taken the code from your post for converting ms to time format.

Sub ConvertToTimeFormat(ms As Long) As String
  Dim seconds, minutes, hours As Int    
  seconds = Round(ms / 1000)
  minutes = Floor(seconds / 60) Mod  60
  hours = Floor(seconds / 3600)
  seconds = seconds Mod 60
  Return NumberFormat(hours, 1, 0) & ":" & NumberFormat(minutes, 2, 0) & ":" & NumberFormat(seconds, 2, 0)
End Sub

It works perfectly well ... Thanks.

I was hoping and wondering if a similar function is available to convert TimeString 0:00:00 to miliseconds so that if i pass this string to my timer then timer can start from same time onwards.

Thanks and regards.


Licensed User
Longtime User
Are you looking for something like this:
Sub ConvertToms(TimeString As String) As Long
    Dim strTime() As String= Regex.Split(":",TimeString)
    Return (strTime(0)*3600 + strTime(1)*60 +strTime(2))*1000
End Sub

Msgbox(ConvertToms("18:25:31"),"")   'displays 66331000
Upvote 0