使用VB將ASP代碼封裝到DLL文件
更新時間:2007年01月10日 00:00:00 作者:
很久以前的文檔,整理出來,回味一下
使用VB封裝ASP,建立SayHello測試程序
1、打開VB6,新建ActiveX DLL
2、在工程引用中加入Microsoft Active Server Pages Object Library選擇
3、填加代碼如下:
'Code Start
'聲明部分
Private MyScriptingContext As ScriptingContext
Private MyApplication As Application
Private MyRequest As Request
Private MyResponse As Response
Private MyServer As Server
Private MySession As Session
'下面定義公用函數(shù)(在VB中訪問ASP對象,即在VB中可以用MyApplication等同于ASP中的Application、MyRequest等同于ASP中的Request、 MyResponse等同于ASP中的Response、 MyServer等同于ASP中的Server、 MySession等同于ASP中的Session 使用)
Public Sub OnStartPage(PassedScriptingContext As ScriptingContext)
Set MyScriptingContext = PassedScriptingContext
Set MyApplication = MyScriptingContext.Application
Set MyRequest = MyScriptingContext.Request
Set MyResponse = MyScriptingContext.Response
Set MyServer = MyScriptingContext.Server
Set MySession = MyScriptingContext.Session
End Sub
Public Sub OnEndPage()
Set MyScriptingContext = Nothing
Set MyApplication = Nothing
Set MyRequest = Nothing
Set MyResponse = Nothing
Set MyServer = Nothing
Set MySession = Nothing
End Sub
'建立自定義函數(shù)SayHello
Public Sub SayHello()
MyResponse.Write ("Hello World")
End Sub
'Code End
4、將類名改為:HelloWorld 將工程名改為:TestVBCode
5、生成TestVBCode.DLL文件,并使用Windows運(yùn)行注冊組件命令Regsvr32 路徑\TestVBCode.DLL注冊后即可使用。(卸載組件命令為Regsvr32 /u 路徑\TestVBCode.DLL)
6、建立Test.asp文件,代碼如下
<%
'VB自建函數(shù)調(diào)用格式
'Set 對象名=Server.CreateObject("工程名.類名")
'對象名.自建函數(shù)名
Set MyTestObj = Server.CreateObject("TestVBCode.HelloWorld")
MyTestObj .SayHello
%>
7、運(yùn)行Test.asp文件結(jié)果顯示如下:
Hello World
以上實例將開啟你的VB編程世界之門
一起來吧,呵呵!
使用VB封裝ASP,建立SayHello測試程序
1、打開VB6,新建ActiveX DLL
2、在工程引用中加入Microsoft Active Server Pages Object Library選擇
3、填加代碼如下:
'Code Start
'聲明部分
Private MyScriptingContext As ScriptingContext
Private MyApplication As Application
Private MyRequest As Request
Private MyResponse As Response
Private MyServer As Server
Private MySession As Session
'下面定義公用函數(shù)(在VB中訪問ASP對象,即在VB中可以用MyApplication等同于ASP中的Application、MyRequest等同于ASP中的Request、 MyResponse等同于ASP中的Response、 MyServer等同于ASP中的Server、 MySession等同于ASP中的Session 使用)
Public Sub OnStartPage(PassedScriptingContext As ScriptingContext)
Set MyScriptingContext = PassedScriptingContext
Set MyApplication = MyScriptingContext.Application
Set MyRequest = MyScriptingContext.Request
Set MyResponse = MyScriptingContext.Response
Set MyServer = MyScriptingContext.Server
Set MySession = MyScriptingContext.Session
End Sub
Public Sub OnEndPage()
Set MyScriptingContext = Nothing
Set MyApplication = Nothing
Set MyRequest = Nothing
Set MyResponse = Nothing
Set MyServer = Nothing
Set MySession = Nothing
End Sub
'建立自定義函數(shù)SayHello
Public Sub SayHello()
MyResponse.Write ("Hello World")
End Sub
'Code End
4、將類名改為:HelloWorld 將工程名改為:TestVBCode
5、生成TestVBCode.DLL文件,并使用Windows運(yùn)行注冊組件命令Regsvr32 路徑\TestVBCode.DLL注冊后即可使用。(卸載組件命令為Regsvr32 /u 路徑\TestVBCode.DLL)
6、建立Test.asp文件,代碼如下
<%
'VB自建函數(shù)調(diào)用格式
'Set 對象名=Server.CreateObject("工程名.類名")
'對象名.自建函數(shù)名
Set MyTestObj = Server.CreateObject("TestVBCode.HelloWorld")
MyTestObj .SayHello
%>
7、運(yùn)行Test.asp文件結(jié)果顯示如下:
Hello World
以上實例將開啟你的VB編程世界之門
一起來吧,呵呵!
相關(guān)文章
ASP.NET Core整合Zipkin鏈路跟蹤的實現(xiàn)方法
這篇文章主要介紹了ASP.NET Core整合Zipkin鏈路跟蹤,本文給大家介紹的非常詳細(xì),對大家的學(xué)習(xí)或工作具有一定的參考借鑒價值,需要的朋友可以參考下2020-09-09
ImageMagickObject獲取圖片的信息無返回值的解決辦法
這篇文章主要介紹了ImageMagickObject獲取圖片的信息無返回值的解決辦法,非常簡單,加上format參數(shù)即可,需要的朋友可以參考下2015-05-05
ASP+MSSQL2000 數(shù)據(jù)庫被批量注入后的解決方法
這陣子,采用ASP+MSSQL設(shè)計的很多網(wǎng)站可能遭遇到sql數(shù)據(jù)庫被掛馬者插入JS木馬的經(jīng)歷;這不,朋友的一個網(wǎng)站就被黑客忽悠了一把2009-02-02
隨機(jī)調(diào)用n條數(shù)據(jù)的方法分析
隨機(jī)調(diào)用n條數(shù)據(jù)的方法分析...2007-07-07
Insert Date and Time into Access
Insert Date and Time into Access...2007-04-04

