VB.net - Format TimeSpan

smithmrk
smithmrk used Ask the Experts™
on
Why am I getting this error (see screen shot)?
And how do I fix it?

Thanks,
Mark
TimeSpanError.PNG
Comment
Watch Question

Do more with

Expert Office
EXPERT OFFICE® is a registered trademark of EXPERTS EXCHANGE®
Database Expert
Awarded 2016
Top Expert 2016
Commented:
This will work.. Please use this.

ts.ToString("hh\:mm")

 Dim time As String = "08:00:00"
        Dim ts As TimeSpan = TimeSpan.Parse(time)
        Dim mark As String = ts.ToString("hh\:mm")

Open in new window


OUTPUT

EE_2.jpg

Author

Commented:
Great Thanks!
Didn't realize I needed the "\"...because some of the  google searches didn't say I needed that.

Mark

Do more with

Expert Office
Submit tech questions to Ask the Experts™ at any time to receive solutions, advice, and new ideas from leading industry professionals.

Start Today