用ASP写组件
更新时间:2006年08月25日 00:00:00 作者:
打开VB,新建AX DLL,工程名为Str,类名count,输入如下代码:
Public Function add(ByVal a As Double, ByVal b As Double, ByVal c As Integer, ByVal d As Integer) As Double
d = CInt(d)
If c = 1 Then '加
add = FormatNumber(a + b, d)
ElseIf c = 2 Then '减
add = FormatNumber(a - b, d)
ElseIf c = 3 Then '乘
add = FormatNumber(a * b, d)
ElseIf c = 4 Then '除
add = FormatNumber(a / b, d)
End If
End Function
参数说明:a,b 为需要计算的数值,c为计算类型,d为小数点保留多少位
客户端ASP文件代码:
set obj=server.CreateObject("str.count")
dim c
c=obj.Add(455,45,4,2)
Response.Write c
上面代码执行结果就是:455除以45,小数点精确到百分位
复制代码 代码如下:
Public Function add(ByVal a As Double, ByVal b As Double, ByVal c As Integer, ByVal d As Integer) As Double
d = CInt(d)
If c = 1 Then '加
add = FormatNumber(a + b, d)
ElseIf c = 2 Then '减
add = FormatNumber(a - b, d)
ElseIf c = 3 Then '乘
add = FormatNumber(a * b, d)
ElseIf c = 4 Then '除
add = FormatNumber(a / b, d)
End If
End Function
参数说明:a,b 为需要计算的数值,c为计算类型,d为小数点保留多少位
客户端ASP文件代码:
复制代码 代码如下:
set obj=server.CreateObject("str.count")
dim c
c=obj.Add(455,45,4,2)
Response.Write c
上面代码执行结果就是:455除以45,小数点精确到百分位
相关文章
GetPaing 函数之asp采集函数中用到的获取分页的代码
GetPaing 函数之asp采集函数中用到的获取分页的代码...2007-09-09asp中的rs.open与conn.execute的区别说明
不管是rs.open sql,conn还是conn.execute(sql) [这里的SQL是delete,update,insert]执行以后都会返回一个关闭的记录集2011-01-01
最新评论