Making numbers  0-9 = 00-09

Posted on 2004-11-08
Last Modified: 2010-05-02
In VB6, how can I make the numbers 0, 1, 2, 3, 4, 5, 6, 7, 8 and 9 appear as 00, 01, 02, 03, 04, 05, 06, 07, 08, and 09... WITHOUT manually doing an IF statement (if variable = 0 then variable.caption = "00", etc.)
Question by:RunBoris
    LVL 7

    Expert Comment

    Hi RunBoris,

    try this:


    LVL 7

    Expert Comment

    sorry, should be

    LVL 5

    Accepted Solution

    Depends where you mean 'appear' but the Format function will do what you want so ...

    MsgBox Format(1, "00")

    will change a 1 into a 01

    Naturally you could pass a variable instead of the 1 if you were in a loop or something.

    So variable.caption = Format(variable,"00")

    Write Comment

    Please enter a first name

    Please enter a last name

    We will never share this with anyone.

    Featured Post

    Enabling OSINT in Activity Based Intelligence

    Activity based intelligence (ABI) requires access to all available sources of data. Recorded Future allows analysts to observe structured data on the open, deep, and dark web.

    When trying to find the cause of a problem in VBA or VB6 it's often valuable to know what procedures were executed prior to the error. You can use the Call Stack for that but it is often inadequate because it may show procedures you aren't intereste…
    Most everyone who has done any programming in VB6 knows that you can do something in code like Debug.Print MyVar and that when the program runs from the IDE, the value of MyVar will be displayed in the Immediate Window. Less well known is Debug.Asse…
    Get people started with the process of using Access VBA to control Outlook using automation, Microsoft Access can control other applications. An example is the ability to programmatically talk to Microsoft Outlook. Using automation, an Access applic…
    Show developers how to use a criteria form to limit the data that appears on an Access report. It is a common requirement that users can specify the criteria for a report at runtime. The easiest way to accomplish this is using a criteria form that a…

    794 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

    Need Help in Real-Time?

    Connect with top rated Experts

    16 Experts available now in Live!

    Get 1:1 Help Now