I have made the following small function to convert a number of sconds supplied to it as an integer, and return a string in a "hh:mm:ss" format. Just wondering if there is a better way to do it with some sort of built in 'Format' instruction? Also, not sure if the 'Mod' operator is a framework instruction?
Thanks for taking a look.VB Code:
Function ConvertToTime(ByVal intNum As Integer) As String 'Convert an integer to a time string "hh:mm:ss" Dim h As String Dim m As String Dim s As String Dim x As String h = CInt(intNum / 3600).ToString 'Calculate hours m = CInt((intNum Mod 3600) / 60).ToString 'Calculate minutes s = CInt(((intNum Mod 3600) Mod 60)).ToString 'Calculate seconds If h.Length = 1 Then h = "0" & h If m.Length = 1 Then m = "0" & m If s.Length = 1 Then s = "0" & s x = h & ":" & m & ":" & s Return x End Function





Reply With Quote