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

Inserting 0 into variable until len = 9

Status
Not open for further replies.

HebieBug

Programmer
Jan 8, 2001
354
JP
Am right in them middile of remaking our Direct debit system. What it does is creates a text file (ABA) which is no problem. There is a place where the ammount of momey to be taken out is represented in 8 didgits eg if it was $850 it would be represented as 00085000
The way that I had it working was to run through a loop and insert the number 0 to the start until it matched length of 8.
There should be an easier way though. Anyone have any ideas on how to make it more proffessionally?
 
Amt = 850
Amt = Right(String(8, "0") & Amt, 8)
? Amt
00000850


Not really any different than John's soloution. I just have tired old eyes and do not like to count characters on screen, so the String function leyts me just TELL doufus how many characters I want.

MichaelRed
mred@att.net

There is never time to do it right but there is always time to do it over
 
yes, John --- but then they really ARE the same?

MichaelRed
mred@att.net

There is never time to do it right but there is always time to do it over
 
OK, I propose this solution...

strFmt = Format(amt * 100, String(8, "0")) Snaggs
tribesaddict@swbell.net
Life can only be understood backwards; but it must be lived forwards.
 
Status
Not open for further replies.

Part and Inventory Search

Sponsor

Back
Top