Split Seconds to Hours, Minutes and Seconds in VB.Net

It's obviously very easy to split a number of seconds into hours, minutes and seconds using division and remainders, but seeing as you've found this page, I guess you're lazy and are after a quick example to copy...

The .Net framework contains a useful object called a TimeSpan object. This example will print 1234 seconds as 0:20:34

	Dim ts As TimeSpan
	Dim sOutput As String

	ts = New TimeSpan(0, 0, 1234)

	sOutput = ts.Hours.ToString & ":" & _
		Format(ts.Minutes, "00") & ":" & _
		Format(ts.Seconds, "00")

Page Updated 03/02/09