用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
參數(shù)說明:a,b 為需要計算的數(shù)值,c為計算類型,d為小數(shù)點保留多少位
客戶端ASP文件代碼:
set obj=server.CreateObject("str.count")
dim c
c=obj.Add(455,45,4,2)
Response.Write c
上面代碼執(zhí)行結(jié)果就是:455除以45,小數(shù)點精確到百分位
復(fù)制代碼 代碼如下:
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
參數(shù)說明:a,b 為需要計算的數(shù)值,c為計算類型,d為小數(shù)點保留多少位
客戶端ASP文件代碼:
復(fù)制代碼 代碼如下:
set obj=server.CreateObject("str.count")
dim c
c=obj.Add(455,45,4,2)
Response.Write c
上面代碼執(zhí)行結(jié)果就是:455除以45,小數(shù)點精確到百分位
相關(guān)文章
GetPaing 函數(shù)之a(chǎn)sp采集函數(shù)中用到的獲取分頁的代碼
GetPaing 函數(shù)之a(chǎn)sp采集函數(shù)中用到的獲取分頁的代碼...2007-09-09JScript中遍歷Request表單參數(shù)集合的方法
這篇文章主要介紹了JScript中遍歷Request表單參數(shù)集合的方法,本文以遍歷Request.QueryString集合為例給出了實現(xiàn)代碼,需要的朋友可以參考下2015-03-03在ASP中不用模板生成HTML靜態(tài)頁直接生成.html頁面
有沒有辦法不用模板,如一個正常的htmer.asp頁面,直接生成為htmer.html頁面呢?當(dāng)然是可以的,而且非常簡單,今天就教大家在ASP中不用模板生成HTML靜態(tài)頁的方法2014-09-09ASP 信息提示函數(shù)并作返回或者轉(zhuǎn)向
這篇文章主要介紹了ASP 信息提示函數(shù)并作返回或者轉(zhuǎn)向,需要的朋友可以參考下2016-12-12asp中的rs.open與conn.execute的區(qū)別說明
不管是rs.open sql,conn還是conn.execute(sql) [這里的SQL是delete,update,insert]執(zhí)行以后都會返回一個關(guān)閉的記錄集2011-01-01