[lnkForumImage]
TotalShareware - Download Free Software

Confronta i prezzi di migliaia di prodotti.
Asp Forum
 Home | Login | Register | Search 


 

(Kathryn)

3/27/2007 7:25:00 PM

Good evening, all!

I have a field that will contain between 2 and four alpha characters
and upto 8 numbers. So all of these are valid:

AB12335
MEAB4567
RNAP3456789
XY87654321

I need to left pad the number to be exactly eight digits. So I need
the above to be:

AB00012335
MEAB00004567
RNAP03456789
XY87654321

The only way I can see to do this is to loop over the the field,
parsing characters one by one, starting at the right most character.
If I get to an alpha character before I get to the ninth character,
insert the appropriate number of zeros.

I keep thinking that there must be a quicker way to do it than this.
Is there, or is that jus wishful thinking?

Kathryn