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

Making numbers 0-9 = 00-09

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.)
0
RunBoris
Asked:
RunBoris
  • 2
1 Solution
 
bkthompson2112Commented:
Hi RunBoris,

try this:

Format(str,"00")

bkt
0
 
bkthompson2112Commented:
sorry, should be

Format(num,"00")
0
 
RogueSolutionsCommented:
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")
0

Featured Post

Vote for the Most Valuable Expert

It’s time to recognize experts that go above and beyond with helpful solutions and engagement on site. Choose from the top experts in the Hall of Fame or on the right rail of your favorite topic page. Look for the blue “Nominate” button on their profile to vote.

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