启动vb6.0,新建-->Active dll工程。单击"工程"-->引用,选择"microsoft active server pages object library"
和"microsoft activeX data objects 2.1 library"两项。将类模块的名称改为myclass.将工程的名称改为mydiy.
在myclass.cls中写入:
Private myscriptingcontext As ScriptingContext
Private myapplication As Application
Private myrequest As Request
Private myresponse As Response
Private myserver As Server
Private mysession As 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
public Sub Msg(AMsg as string) as string
Dim a
Response.write AMSg & "<br>"
End Sub
编译生成myclass.dll文件。注册regsvr32 路径\myclass.dll。
用visual interdev打开global.asa文件.当然了,你也可以在其它文件中使用。
set dcss=server.CreateObject("mydiy.myclass")
dcss.msg("hello!")