Left Pad

G

Guest

How would one left pad a string with a repeating character?
For example, to create a 9 character string left padded with zeroes:

999 should become 000000999
1 should become 000000001

and so on...

Thanks for any help!
 
H

Herfried K. Wagner [MVP]

Mark said:
How would one left pad a string with a repeating character?
For example, to create a 9 character string left padded with zeroes:

999 should become 000000999
1 should become 000000001

\\\
MsgBox("999".PadLeft(10, "0"))
///
 
D

dgk

\\\
MsgBox("999".PadLeft(10, "0"))
///

PadLeft? String has a PadLeft? They thought of almost everything.
Look, there's a PadRight too! There goes Lset and Rset, if they aren't
gone already.
 
H

Herfried K. Wagner [MVP]

dgk said:
PadLeft? String has a PadLeft?

Yes :)!
There goes Lset and Rset, if they aren't gone already.

These methods are still supported. However, they can only be used to use
space characters as padding character.
 

Ask a Question

Want to reply to this thread or ask your own question?

You'll need to choose a username for the site, which only take a couple of moments. After that, you can post your question and our members will help you out.

Ask a Question

Top