Link to home
Start Free TrialLog in
Avatar of neelyjer
neelyjerFlag for United States of America

asked on

Number Formatting

Hello Experts,

     I would like to format a sinlge digit number as a 2 digit.  Let's say I have the following:

Var1 = 1
Var1 = Var1 + 2
MsgBox "The value of Var1 is " Var1 "."

Instead of the msg displaying "The value of Var1 is 3", I'd like it to display the following:

"The value of Var1 is 03"

I'm not sure how to format Var1 to always be 2 digits for single digit numbers.

Thanks Experts,

Jeremy
Avatar of neelyjer
neelyjer
Flag of United States of America image

ASKER

FYI, I'm using VB6.
Avatar of Jim Horn
MsgBox "The value of Var1 is " &  format(Var1, "00") & "."
ASKER CERTIFIED SOLUTION
Avatar of Jerbe
Jerbe
Flag of Sweden image

Link to home
membership
This solution is only available to members.
To access this solution, you must be a member of Experts Exchange.
Start Free Trial
Thanks for the comments.  I'd actually like to have the variable hold the 2 digit value.  Is that possible?
>I'd actually like to have the variable hold the 2 digit value.  Is that possible?
Only if the variable is ultimately a string, as numeric columns/variables by default do not support leading zeros.

sStringVariable = CStr(AnyNumericVariable)