Bill wrote on 07 jul 2004 in microsoft.public.inetserver.asp.general:
Evertjan. said:
1 there is no "best way" in programming.
2 you do not specify a language [under ASP, there are different
languages.
==========
examples [if myNum is an integer between 0 and 99 inclusive]:
vbscript:
myStr = right("0"&myNum,2)
javascript:
myStr = ((myNum<10)?"0":"")+myNum
[please do not toppoat on usenet]
I meant VBScript, because it's an ASP group, isn't it?
Your assumption is wrong, Bill. ASP does not "mean" vbscript, it can just as well use(!)
vbscript as j[ava]script. So in this NG you should always specify. The default language
can be specified on the IIS host and can also be jscript.
Yeah, there's no "best way" in programming, duh.
An important concideration. Personal programmer preferences of style/elegance,
conciseness, processor load or debugability are valid.
I'm using this:
Right("0" & FormatNumber(nNum), 2)
Why the formatnumber()? If nNum is not an integer between 0 and 99, You will get the
wrong string anyway.
Your VBScript example uses a numeric as a string. Not a good thing to
do.
It does not, These are not typed variables, only typed variable content.
I use the automatic type conversion of these two scripting languages.
Why is that not a good thing?
Automatic type conversion is explicitly included in the languages.