Forum Moderators: open

Message Too Old, No Replies

FormatNumber

Trying to format a number with a leading zero

         

davemarks

8:04 pm on Apr 5, 2003 (gmt 0)

10+ Year Member



I'm trying to generate a list of numbers 01-12

ie 01,02,03,04,05,06,07,08,09,10,11,12

This is what I have so far...


FOR i = 01 TO 12
Response.Write("<option>" & FormatNumber(i,0,-1,0,0) & "</option>")
NEXT

But this isn't getting me anywhere.

Can you help?

Thanks in advance

davemarks

8:14 pm on Apr 5, 2003 (gmt 0)

10+ Year Member



Isn't it always the way. You spend several hours with a problem in the back of your head. Finally you give up searching for an answer and post on a forum.

Then less than 10 mins later you suss the answer!

It sudddenly dawned on me that, it didn't really need to be a number, so all this FormatNumber stuff was looking at it from the wrong angle. So I did this...

FOR i = 01 TO 12
IF i < 10 THEN i = "0" & i END IF
Response.Write("<option>" & i & "</option>")
NEXT

Cheers all the same!

olwen

8:30 pm on Apr 5, 2003 (gmt 0)

10+ Year Member



I see you cam up with a similar answer to mine. I would have done

FOR i = 1 TO 12
j = right("0"&i,"2" )
Response.Write("<option>" & j & "</option>")
NEXT

But I think you should be able to mask the number for leading zeros.