添加模块代码,此段代码几乎适用于所有使用vb封装的asp DLL组件中,其中的ASP2DLL更改为工程名或者在调用时保持一致即可,代码如下: 复制代码 代码如下: Public objContext As ObjectContext Public Application As ASPTypeLibrary.Application Public Server As ASPTypeLibrary.Server Public Session As ASPTypeLibrary.Session Public Response As ASPTypeLibrary.Response Public Request As ASPTypeLibrary.Request Public Sub ASP2DLL_Initialize() On Error Resume Next Set objContext = GetObjectContext Set Application = objContext.Item("Application") Set Server = objContext.Item("Server") Set Session = objContext.Item("Session") Set Request = objContext.Item("Request") Set Response = objContext.Item("Response") End Sub Public Sub ASP2DLL_Terminate() On Error Resume Next Set Application = Nothing Set Server = Nothing Set Session = Nothing Set Request = Nothing Set Response = Nothing Set objContext = Nothing End Sub Public Function Eval(ByRef strEval) Dim EvalObject As New ScriptControl EvalObject.Language = "VBScript" Eval = EvalObject.Eval(strEval) Set EvalObject = Nothing End Function
4、保存新创建的DLL 文件-->保存工程,一路确定下来,将模块、类模块、工程文件全部保存在一个文件夹下 5、类模块中调用ASP对象 工程资源管理器-->类模块-->双击Demo切换到Demo类模块代码编辑器,贴上代码,初始化类调用及类销毁,代码如下: 复制代码 代码如下: Private Sub Class_Initialize() ASP2DLL_Initialize End Sub Private Sub Class_Terminate() ASP2DLL_Terminate End Sub