• Status: Solved
  • Priority: Medium
  • Security: Public
  • Views: 273
  • Last Modified:

display an int with 1 or 2 digits as a 2 digit number?

If I have an integer with 1 or 2 digits e.g. 1 or 9 or 11 how can I display it as two digits?

i.e.
01, 09 and 11

There must be a function of something instead of inspecting the int and adding a '0' to the begining of it if it is only 1 digit long

Thanks
0
se402036se
Asked:
se402036se
1 Solution
 
TimCotteeCommented:
Hi se402036se,

Msgbox MyInteger.ToString("00")

It is the display that is important, a numeric cannot have formatting so you need to convert it to a string with the appropriate formatting.

Tim Cottee
0
 
ZeonFlashCommented:
You can also try MyInteger.ToString.Padleft(2, "0")
0

Featured Post

Free Tool: ZipGrep

ZipGrep is a utility that can list and search zip (.war, .ear, .jar, etc) archives for text patterns, without the need to extract the archive's contents.

One of a set of tools we're offering as a way to say thank you for being a part of the community.

Tackle projects and never again get stuck behind a technical roadblock.
Join Now