Solved

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

Posted on 2006-07-17
2
267 Views
Last Modified: 2010-04-23
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
Comment
Question by:se402036se
[X]
Welcome to Experts Exchange

Add your voice to the tech community where 5M+ people just like you are talking about what matters.

  • Help others & share knowledge
  • Earn cash & points
  • Learn & ask questions
2 Comments
 
LVL 43

Accepted Solution

by:
TimCottee earned 25 total points
ID: 17122049
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
 
LVL 17

Expert Comment

by:ZeonFlash
ID: 17122948
You can also try MyInteger.ToString.Padleft(2, "0")
0

Featured Post

Free Tool: Site Down Detector

Helpful to verify reports of your own downtime, or to double check a downed website you are trying to access.

One of a set of tools we are providing to everyone as a way of saying thank you for being a part of the community.

Question has a verified solution.

If you are experiencing a similar issue, please ask a related question

Introduction When many people think of the WebBrowser (http://msdn.microsoft.com/en-us/library/2te2y1x6%28v=VS.85%29.aspx) control, they immediately think of a control which allows the viewing and navigation of web pages. While this is true, it's a…
If you need to start windows update installation remotely or as a scheduled task you will find this very helpful.
Michael from AdRem Software explains how to view the most utilized and worst performing nodes in your network, by accessing the Top Charts view in NetCrunch network monitor (https://www.adremsoft.com/). Top Charts is a view in which you can set seve…
This is my first video review of Microsoft Bookings, I will be doing a part two with a bit more information, but wanted to get this out to you folks.

695 members asked questions and received personalized solutions in the past 7 days.

Join the community of 500,000 technology professionals and ask your questions.

Join & Ask a Question