Code.Blog

Code Talk for the Application/Game Developer

  Home  |   Contact  |   Syndication    |   Login
  99 Posts | 0 Stories | 44 Comments | 0 Trackbacks

News

View Matt Christian's profile on LinkedIn

Twitter












Archives

My Sites

I just had to padd an integer with zeros when I displayed it and thought it would be a good piece of code to post considering there are some crazy difficult versions of doing this on the net that seem quite unnecessary.

iNum.ToString("000")

This will pad iNum with leading zeros if it's length is smaller than 3.  For example, if iNum = 42, the output would be the string "042".

HERE's a great MS resource for numerous ways to pad strings including with zeros and blank spaces (it's about padding in PowerShell but the general concepts still apply to VB, I can assume it would with C# as well).

posted on Wednesday, August 06, 2008 10:46 AM