Tek-Tips is the largest IT community on the Internet today!

Members share and learn making Tek-Tips Forums the best source of peer-reviewed technical information on the Internet!

  • Congratulations Westi on being selected by the Tek-Tips community for having the most helpful posts in the forums last week. Way to Go!

Format variable with trailing zeros

Status
Not open for further replies.

EddyLLC

Technical User
Mar 15, 2005
304
US
This should be a simple but I'm vapor locked. I have a variable, dimmed as a string that has a number it represents. I want to pad the right side of the string with 0,s that's zeros so the variable is 10 characters long. For example I want the variable that equals 456 to be 4560000000. I tried the following code
strNumber = Format(str1,"0000000000)

but this places the zeros on the left side and I need them on the right.

Thanks
 
Something like this ?
strNumber = Left(str1 & "0000000000", 10)

Hope This Helps, PH.
Want to get great answers to your Tek-Tips questions? Have a look at FAQ219-2884 or FAQ181-2886
 
Thanks for the response. I tried your suggestion in the immediate window while running the code and it returned a False. I don't know what I'm doing wrong. str1 has a value but the value will be different at times so I won't know how many zeros to add at the end of it. The Format function works great but puts the zeros in front of my string and not at the end of it where I need them.
 
I guess you typed this ?
? strNumber = Left(str1 & "0000000000", 10)
What about type this instead ?
? Left(str1 & "0000000000", 10)

Hope This Helps, PH.
Want to get great answers to your Tek-Tips questions? Have a look at FAQ219-2884 or FAQ181-2886
 
Your nailed it. Thanks for the help. Now it's time to get my hour and a half sleep.

Thanks again.
 
Status
Not open for further replies.

Part and Inventory Search

Sponsor

Back
Top