Home All Groups Group Topic Archive Search About

Formatting a string with leading zeroes.

Author
26 Jan 2006 4:04 AM
Andrew Chalk
If I have a number representing a number of minutes and I want to format it
as a string with two characters, with a leading 0 if the value is less than
10, how do I do that?

Many thanks.

Author
26 Jan 2006 6:32 AM
Mattias Sjögren
Andrew,

>If I have a number representing a number of minutes and I want to format it
>as a string with two characters, with a leading 0 if the value is less than
>10, how do I do that?

number.ToString("00")


Mattias

--
Mattias Sjögren [C# MVP]  mattias @ mvps.org
http://www.msjogren.net/dotnet/ | http://www.dotnetinterop.com
Please reply only to the newsgroup.
Author
27 Jan 2006 4:36 AM
Syed Abbas Naqvi
Try this out.
strNumber = Format(yourNumber,"00")
Author
27 Jan 2006 6:27 PM
Andrew Chalk
Thanks, to Mattias as well. I will try that.

- A
Show quote
"Syed Abbas Naqvi" <abbas.***@gmail.com> wrote in message
news:1138336611.183293.115530@z14g2000cwz.googlegroups.com...
> Try this out.
> strNumber = Format(yourNumber,"00")
>

AddThis Social Bookmark Button