本文介绍了在ASP经典和FormatNumber结果计算的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

我的previous文章后(其中每个人都真正有用的 - 感谢)香港专业教育学院打到现在另一个问题......计算和FormatNumber结果

After my previous post (in which everyone was really helpful - thanks) ive now hit another issue... Calculations and to FormatNumber the result.

我在SQL 3字段我需要做一个简单的计算与当时的结果需要有FormatNumber适用于它。

I have 3 fields in SQL that i need to do a simple calculation with then the result needs to have FormatNumber applied to it..

字段

OverallFee,WIPFee,RenderedFee - 所有的都是数字

"OverallFee" , "WIPFee" , "RenderedFee" - all are numeric

整个表,他们填充细跟下面。

throughout the table they populate fine with the below.

<td width="100" align="center" class="style1"><% If Not IsNull(rs("OverallFee")) Then Response.Write ("£" + FormatNumber(rs("OverallFee"),0)) End If %></td>
<td width="100" align="center" class="style1"><% If Not IsNull(rs("RenderedFee")) Then Response.Write ("£" + FormatNumber(rs("RenderedFee"),0)) End If %></td>
<td width="100" align="center" class="style1"><%=rs("WIPFee")%></td>

现在我需要做一个计算 -

Now I need to do a calculation -

("OverallFee"/100) * "WIPFee" - "RenderedFee"

我试过

<td width="50" align="center" class="style1"><%=((rs("OverallFee")/100)*rs("WIPFee")-rs("RenderedFee"))%></td>

它应该工作,但我发现

It should work but I'm getting

Microsoft VBScript运行时错误800a000d - 类型不匹配

在该行与我被困...

on that line and I'm stuck...

我这样做是正确的...有没有更简单的方法?

Am I doing it right... is there an easier way?

推荐答案

尝试将数据转换为长 CLng函数或双 CDbl

Try to convert your data to long CLng or double CDbl

<%
    calc = 0 'Or a text to display

    If Not IsNull(rs("RenderedFee")) And Not IsNull(rs("OverallFee")) And Not IsNull(rs("WIPFee")) Then
        calc = (CLng(rs("OverallFee"))/100)*CLng(rs("WIPFee"))-CLng(rs("RenderedFee"))
    End If
%>

<td width="50" align="center" class="style1"><%=calc%></td>

这篇关于在ASP经典和FormatNumber结果计算的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持!

07-24 19:25