Tek-Tips is the largest IT community on the Internet today!

Members share and learn making Tek-Tips Forums the best source of peer-reviewed technical information on the Internet!

  • Congratulations TouchToneTommy on being selected by the Tek-Tips community for having the most helpful posts in the forums last week. Way to Go!

Help!!FormatPercent error

Status
Not open for further replies.

Herminio

Technical User
May 10, 2002
189
PT

I have this lines of code here, when i run in my computer it works fine, but online it gives me the error that you can see on the end of this post
...
<%
vtpg1 = rsRes(&quot;resp1&quot;)
vtpg2 = rsRes(&quot;resp2&quot;)
vtpg3 = rsRes(&quot;resp3&quot;)

if rsRes(&quot;totalvotos&quot;) = 0 then %>
<FONT SIZE=&quot;&quot; COLOR=&quot;orange&quot;>Ainda não foram introduzidas respostas na votação seleccionada</FONT><br>
<A HREF=&quot;#&quot; onclick=&quot;history.back()&quot;>Voltar</A>
<% else %>
<%
results1 = rsRes(&quot;resp1&quot;) / rsRes(&quot;totalvotos&quot;)
results2 = rsRes(&quot;resp2&quot;) / rsRes(&quot;totalvotos&quot;)
results3 = rsRes(&quot;resp3&quot;) / rsRes(&quot;totalvotos&quot;)
%>
</div>
<table border=&quot;0&quot; align=&quot;center&quot;>
<tr>
<td colspan=&quot;4&quot;><FONT SIZE=&quot;&quot; COLOR=&quot;orange&quot;><%=rsRes(&quot;Assunto&quot;)%></FONT></td>
</tr>
<tr>
<td width=&quot;35&quot;><FONT SIZE=&quot;&quot; COLOR=&quot;orange&quot;><%=rsRes(&quot;Perg1&quot;)%>:</FONT></td>
<td width=&quot;7&quot;><img src=&quot;Imagens/amarelo.jpg&quot; width=&quot;<%=rsRes(&quot;Resp1&quot;)%>&quot; height=&quot;15&quot;></td>
-->This is line 57<td width=&quot;20&quot;><FONT SIZE=&quot;2&quot; color=orange><%=FormatPercent(results1,1)%></FONT></td>
<td width=&quot;71&quot;><FONT SIZE=&quot;2&quot; color=orange>(<%=vtpg1%>)</FONT></td>
</tr>
...


Microsoft VBScript runtime error '800a000d'
Type mismatch: 'FormatPercent'
/votos/results.asp, line 57

Can anyone tell me what's the problem, i'm running on Brinkster
 
hey there.
there some common checks you can take when you get type mismatch errors, but the main one is to check for the data type of the variable or rs you are trying to use a built in function with
CInt = integer
Clng = long integer
CStr = string
Cdate = date

so, test it!
<%=FormatPercent(CInt(results1),1)%>
that one may fix this seeing as FormatPercent cannot format a string value and that would be the most likely cause _______________________________________________
{ str = &quot;sleep is good for you. sleep gives you the energy you need to function&quot;;
ptr = /sleep/gi;Nstr = str.replace(ptr,&quot;coffee&quot;);alert(Nstr); }

_______________________________________________
for the best results to your questions: FAQ333-2924

 
I there onpt, i've tried what you sugest and now it gives this

Microsoft VBScript runtime error '800a005e'

Invalid use of Null: 'CInt'

/votos/results.asp, line 57

 
thanks for your help onpt, i've managed to solve the problem, i've not set predifined value to 0 in the field and obviously it could not show a percent value of a Null field, thanks anyway
 
glad you got it.
keep the debug methods in mind still. it can save hours of hair pulling with a few checks. _______________________________________________
{ str = &quot;sleep is good for you. sleep gives you the energy you need to function&quot;;
ptr = /sleep/gi;Nstr = str.replace(ptr,&quot;coffee&quot;);alert(Nstr); }

_______________________________________________
for the best results to your questions: FAQ333-2924

 
Status
Not open for further replies.

Part and Inventory Search

Sponsor

Back
Top