添加模塊代碼,此段代碼幾乎適用于所有使用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