Force prevailing 0 on single integer

P

Pooley

Is there an easy way to force ASP to display integers less than 10 thus:
01, 02, 03 etc...

There must be an easier way than doing an If < 10 calculation etc. and
adding a prevailing '0' - mustn't there....?

Thanks.
 
E

Evertjan.

Pooley wrote on 14 jan 2004 in microsoft.public.inetserver.asp.general:
Is there an easy way to force ASP to display integers less than 10 thus:
01, 02, 03 etc...

There must be an easier way than doing an If < 10 calculation etc. and
adding a prevailing '0' - mustn't there....?

See John Stockton's

<http://www.merlyn.demon.co.uk/js-maths.htm#LZ>

That is Javascript, but if you prefer VBscript the principles are easily
ported.

In short it depends on what input you allow, negatives allowed? etc
 
D

Dan Boylett

Pooley said:
Is there an easy way to force ASP to display integers less than 10 thus:
01, 02, 03 etc...

There must be an easier way than doing an If < 10 calculation etc. and
adding a prevailing '0' - mustn't there....?

If you're reading data from a database you could amend the procedure to
return the data formatted as you like.

However you do it though, you will need to do some form of If < 10 !!
 
W

William Morris

You'd handle this in your output, since there's no way I know of to STORE an
integer with leading zeros. Try:

dim myval
myVal = "5"
response.write right("00" & myVal, 2)
'--- returns "05"
myVal = "25"
response.write right("00" & myVal, 2)
'--- returns "25"
 

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

Members online

No members online now.

Forum statistics

Threads
473,769
Messages
2,569,579
Members
45,053
Latest member
BrodieSola

Latest Threads

Top