Tek-Tips is the largest IT community on the Internet today!

Members share and learn making Tek-Tips Forums the best source of peer-reviewed technical information on the Internet!

  • Congratulations gkittelson on being selected by the Tek-Tips community for having the most helpful posts in the forums last week. Way to Go!

Numeric Formatting

Status
Not open for further replies.

gmltc1

Programmer
Jul 10, 2003
2
US
For the first I am delving into the realm of formatting numbers. Basically I have a number that will from 0 to 60 and need to add a leading zero to it if less than 10. Output would be like: 01 or 07, etc. The number is stored in a decimal (due to previous math done to it). Ultimately it will end up in a string.

Appreciate any thoughts.
 
This is documented at:

ms-help://MS.VSCC/MS.MSDNVS/cpguide/html/cpconcustomnumericformatstrings.htm

But basically, you would do this:
Code:
int MyInt = 8;
string MyString = MyInt.ToString("00");
Chip H.


If you want to get the best response to a question, please check out FAQ222-2244 first
 
chiph,
Thanks for the help. I dug high and low through the MSDN and other online resources, but still struggled some. What you posted was what was simply needed.
 
Glad to help.

Chip H.


If you want to get the best response to a question, please check out FAQ222-2244 first
 
Status
Not open for further replies.

Part and Inventory Search

Sponsor

Back
Top