VBscript FormatPercent overflow 800a0006

D

dkiernan

I am stumped. I have several websites running on a 2003 IIS6 box, all
running basically the same code (each site has its own home directory
and copy of the code). All are running in the same App Pool.

One site gives the 800a0006 error on a formatpercent, another site (on
the same server) does not.

Here's the kicker...the one site only fails if the number is LESS THAN
1.

formatpercent(0.999) ---> overflow
formatpercent(1.000) ---> 100%

The one "abnormality" is that the default script language is set to
jscript, and I call the function via a call to a vbscript block -- but
this works on several other sites on this same server.

Any clues?
 
D

dkiernan

Follow-up on previous post.

I have narrowed it down to the fact that I call the vbscript code from
jscript code, and anything with a decimal in the number fails.

Changing the default page language to vbscript and calling
formatpercent directly works fine for any number.

What is most peculiar (not to mention *extremely* frustrating) is that
this same code on another site on the same server works fine. I've
deleted/recreated the web app in IIS as well.

<%@language=jscript%>

<script language=vbscript runat=server>
function frmtPercent (nNumber)
fmrtPercent = formatpercent(nNumber,2)
end function
</script>

<%
frmtPercent(0) --> 0.00%
frmtPercent(1) --> 100.00%
fmrtPercent(0.5) --> overflow 800a0006
%>

Please help....


wrote:
 
E

Evertjan.

wrote on 18 sep 2006 in microsoft.public.inetserver.asp.general:
Follow-up on previous post.

I have narrowed it down to the fact that I call the vbscript code from
jscript code, and anything with a decimal in the number fails.

Changing the default page language to vbscript and calling
formatpercent directly works fine for any number.

What is most peculiar (not to mention *extremely* frustrating) is that
this same code on another site on the same server works fine. I've
deleted/recreated the web app in IIS as well.

Could be a IIS version problem?
<%@language=jscript%>

<script language=vbscript runat=server>
function frmtPercent (nNumber)
fmrtPercent = formatpercent(nNumber,2)
end function
</script>

<%
frmtPercent(0) --> 0.00%

Like this, it returns nothing.
frmtPercent(1) --> 100.00%
fmrtPercent(0.5) --> overflow 800a0006
%>

Please help....

The below, which should be copied to an empty test.asp,
works fine here,
please test:

<%@language=jscript%>

<%
var x = 0;
response.write(x+'<br>');
response.write(fmrtPercent(x)+'<br>');
x = 7;
response.write(x+'<br>');
response.write(fmrtPercent(x)+'<br>');
x = 0.7;
response.write(x+'<br>');
response.write(fmrtPercent(x)+'<br>');

response.write(0.5+'<br>');
response.write(fmrtPercent(0.5)+'<br>');
%>

<script language=vbscript runat=server>
function fmrtPercent(nNumber)
fmrtPercent = formatpercent(nNumber,2)
end function
</script>

and returns:

0
0.00%
7
700.00%
0.7
70.00%
0.5
50.00%
 
D

Dave Anderson

<script language=vbscript runat=server>
function frmtPercent (nNumber)
fmrtPercent = formatpercent(nNumber,2)
end function
</script>

<%
frmtPercent(0) --> 0.00%
frmtPercent(1) --> 100.00%
fmrtPercent(0.5) --> overflow 800a0006
%>

Does it help if you change your function like this? VBScript functions like
this may not be able to handle all numeric data types.

Function frmtPercent (nNumber)
frmtPercent = formatpercent(CSng(nNumber),2)
End Function


Also, it helps to spell your function correctly in your interior assignment
(frmtPercent is not the same as fmrtPercent).
 
D

dkiernan

Typos were introduced in composing the posting...sorry.

I copied the website to a different server box running same os, same
IIS, same patch levels. It works fine. Also, as I mentioned, the same
code on the same box as the failing code is also working.

In addition, the code works for any integer source value (0, 1, -1, 5,
etc.). It is only when I call the formatpercent function with a
decimal number.

I went further and hardcoded values in the vbscript function, so the
value passed from jscript is ignored completely -- same results.

See code below, if the value in the vbscript function is changed to
1.01, it fails. So I know that it is not the value passed by jscript.

<%@language=jscript%>

<script language=vbscript runat=server>
function frmtPercent (nPercent)
frmtPercent = formatpercent(1.00)
end function
</script>

<%
x = 0.050
Response.write (frmtPercent(x));
%>

For some reason, vbscript formatpercent just does not like decimal
numbers just on this one site on this server.

--David
 
E

Evertjan.

wrote on 18 sep 2006 in microsoft.public.inetserver.asp.general:
<%
x = 0.050
Response.write (frmtPercent(x));
%>

For some reason, vbscript formatpercent just does not like decimal
numbers just on this one site on this server.

What about regional settings?
 
D

dkiernan

First -- Thanks for all the suggestions, guys, I appreciate your time
and assistance!

I didn't try your suggestion because it didn't seem to be related to
the variable being sent from the jscript.

I just now tried changing the vbscript function frmtPercent to call
formatpercent(CSng(nNumber)) as suggested and still get the overflow
error.

What in regards to regional settings should I look at? Is that per
site? I have not specifically set anything. As mentioned, I have
deleted and created a new Web Site in IIS. It is just this one site on
this one box. I will try putting it in a different App Pool in IIS.

In fact, this code (below) works as is on a different site on that box,
but not on this site. I literally copied from the non-working site to
another and it works.

<%@language=jscript%>
<script language=vbscript runat=server>

function formatPerc (nPercent)
formatPerc = formatpercent (nPercent,2)
end function
</script>

<%
var n = Number(1.1)
Response.write (n + ' before')
Response.write (formatPerc(n),' after')
%>
 

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,982
Messages
2,570,185
Members
46,736
Latest member
AdolphBig6

Latest Threads

Top