What would be the equivalent in VB.NET of the time format [h]:mm in EXCEL ?

Hi Experts

In EXCEL, we have a very practical time format [h]:mm that preserve the hours in hours. For example, 25 hours in [h]:mm would be expressed as 25:00 instead of 01:00 for all other formats with hh, like hh:mm or HH:mm.

What would be the equivalent in VB.NET of this very neat format? Is there a simple way to format 25 hours in VB.NET like 25:00 ? Do I have to build a formatting method of my own?

Thank you for the information.

mojoansoolAsked:
Who is Participating?
I wear a lot of hats...

"The solutions and answers provided on Experts Exchange have been extremely helpful to me over the last few years. I wear a lot of hats - Developer, Database Administrator, Help Desk, etc., so I know a lot of things but not a lot about one thing. Experts Exchange gives me answers from people who do know a lot about one thing, in a easy to use platform." -Todd S.

Jorge PaulinoIT Pro/DeveloperCommented:
I don't think you have ... but you can build your own
Dim time As New TimeSpan(10, 5, 0) ' 10:05:00
Dim newTime As TimeSpan = time.Add(New TimeSpan(25, 0, 0)) ' Add 25 hours

Debug.WriteLine(String.Format("{0}:{1}", newTime.TotalHours.ToString("00"), _
                                              newTime.Minutes.ToString("00")))

Open in new window

0

Experts Exchange Solution brought to you by

Your issues matter to us.

Facing a tech roadblock? Get the help and guidance you need from experienced professionals who care. Ask your question anytime, anywhere, with no hassle.

Start your 7-day free trial
Alexandre SimõesManager / Technology SpecialistCommented:
How do you get that value?

If you use a TimeSpan you can simply get the Hours and the minutes.


Dim ts As New TimeSpan(25, 22, 0)
Dim time As String = (ts.Hours.ToString() & ":") + ts.Minutes.ToString()
0
mojoansoolAuthor Commented:
For this format I'm looking for, I guess I will have to settle for a custom build.  In the mean time, jpaulino made me realize the existence of the TimeSpan structure. Thanks.
0
It's more than this solution.Get answers and train to solve all your tech problems - anytime, anywhere.Try it for free Edge Out The Competitionfor your dream job with proven skills and certifications.Get started today Stand Outas the employee with proven skills.Start learning today for free Move Your Career Forwardwith certification training in the latest technologies.Start your trial today
Programming Languages-Other

From novice to tech pro — start learning today.