|
-
Jan 9th, 2001, 01:24 PM
#1
Thread Starter
Hyperactive Member
Hi,
I tryed this:
<%=format(7,"000")%> in hopes I'd get 007 like in VB
But I got this:
Microsoft VBScript runtime error '800a000d'
Type mismatch: 'format'
I need to insure three place holders are taken at all times for any integer 1 to 999. Any Help?
-
Jan 9th, 2001, 01:44 PM
#2
New Member
asp Vb Script have only few format functions (currency,percent...), but you can write your own format function. For your example:
function format(number,length)
dim i
if len(number)>length then
format="ERR"
else
for i=1 to length-len(number)
format=format & "0"
next
format=format & number
end if
end function
And then in code just call
<%format(7,3)%>
If you wil try to format number in less places then the length of number, you will get ERR.
Hope it helps, Maxi
Posting Permissions
- You may not post new threads
- You may not post replies
- You may not post attachments
- You may not edit your posts
-
Forum Rules
|
Click Here to Expand Forum to Full Width
|