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 strongm on being selected by the Tek-Tips community for having the most helpful posts in the forums last week. Way to Go!

Zero fill a string - format? array?

Status
Not open for further replies.

lora

Programmer
Dec 1, 1999
43
US
I have to convert a number to a string; of course that's the easy part...then I need to make the string 9 characters long with leading zeros:

strBalanceSc = (rstOCR!Balance * 100)

Right now the answer to this is "59925"

I need 000059925.

Any ideas?? Thanks!

Lora
 
answered my own question!! code is:

strBalanceSc = Mid(rstOCR!Balance / 10000000, 3, 9)
 
Hi,

You could also use:

strBalanceSc = format((rstOCR!Balance * 100),"000000000")

 
THANKS...mine doesn't work if your balance contains zero but your's does!
ie 522.25 works with mine but 522.00 only gives me seven characters instead of nine...
 
Try the simple way
Ie. Put too many zeros on the start and then take the right most characters you need.

T1 = Right("00000000000000" & str(Number*100),9)
 
Status
Not open for further replies.

Part and Inventory Search

Sponsor

Back
Top