I would like to get a time (for example 03:00:03) feeding only the seconds, but nothing else.
Using the Microsoft.VisualBasic runtime, I could say
Dim sTimeRemaining As String = DateAndTime.TimeSerial(0, 0, iSecondsRemaining)
I would use this to show the user how long a download is still going to take.
Can somebody tell me how to do this without the Microsoft.VisualBasic runtime?
Thank you!
You could use
Dim sTimeRemaining As Date = New Date().AddSeconds(iSecondsRemaining)
Note that you should set Option Strict to On. Then your code wouldn't compile since DateAndTime.TimeSerial returns a Date and not a String. But it's a good thing because you are forced to build more robust and type safe code.
Perhaps it would also be better to use a TimeSpan instead of a Date in this case.
Dim seconds = TimeSpan.FromSeconds(iSecondsRemaining)
If you love us? You can donate to us via Paypal or buy me a coffee so we can maintain and grow! Thank you!
Donate Us With