Question:

In Visual Basic Express 2008, how do I convert integer numbers into a hh:mm:ss format or mm:ss format, Thanks?

by Guest58589  |  earlier

0 LIKES UnLike

I have an integer variable that reads 160 and i want it to display 2:40 or 0:02:40.. Either format works fine. I am a beginner at this, thank alot.

 Tags:

   Report

3 ANSWERS


  1. Check out the link in the source.


  2. PRINT INT(num/60); ":"; num MOD 60

    INT(num/60) takes the integer value of the number you are processing- it converts the seconds into minutes.

    num MOD 60 takes the remainder seconds if you subtract all the whole minutes.

  3. Dim intSeconds As Integer = 160

    Dim nanoSecondTime As Long = CType(intSeconds, Long) * 10000000

    Dim ts As New TimeSpan(nanoSecondTime)

    Label1.Text = ts.ToString()

    I just noticed there is a problem with massive_cube_of_legos answer.  If you have an integer that is more than a day (in seconds) it will give you 25 which I'm assuming is not what you want.

Question Stats

Latest activity: earlier.
This question has 3 answers.

BECOME A GUIDE

Share your knowledge and help people by answering questions.