A long time ago document, sorted out and reminisce
Use VB to encapsulate ASP and establish a SayHello test program
1. Open VB6 and create a new ActiveXDLL
2. Add Microsoft ActiveServerPagesObjectLibrary to the project reference
3. Fill in the code as follows:
'CodeStart
'Declaration Part
PrivateMyScriptingContextAsScriptingContext
PrivateMyApplicationAsApplication
PrivateMyRequestAsRequest
PrivateMyResponseAsResponse
PrivateMyServerAsServer
PrivateMySessionAsSession
'The following defines a common function (accessing the ASP object in VB, that is, in VB, MyApplication can be used to be equivalent to Application in ASP, MyRequest is equivalent to Request in ASP, MyResponse is equivalent to Response in ASP, MyServer is equivalent to Server in ASP, MySession is equivalent to Session in ASP)
PublicSubOnStartPage(PassedScriptingContextAsScriptingContext)
SetMyScriptingContext=PassedScriptingContext
SetMyApplication=MyScriptingContext.Application
SetMyRequest=MyScriptingContext.Request
SetMyResponse=MyScriptingContext.Response
SetMyServer=MyScriptingContext.Server
SetMySession=MyScriptingContext.Session
EndSub
PublicSubOnEndPage()
SetMyScriptingContext=Nothing
SetMyApplication=Nothing
SetMyRequest=Nothing
SetMyResponse=Nothing
SetMyServer=Nothing
SetMySession=Nothing
EndSub
'Create custom function SayHello
PublicSubSayHello()
MyResponse.Write("HelloWorld")
EndSub
'CodeEnd
4. Change the class name to: HelloWorld Change the project name to: TestVBCode
5. Generate the TestVBCode.DLL file and use Windows to run the Regsvr32 path/TestVBCode.DLL to register and use it. (The uninstall component command is Regsvr32/u path/TestVBCode.DLL)
6. Create the Test.asp file, the code is as follows
<%
'VB self-built function call format
'Set object name=Server.CreateObject("Project name.Class name")
'Object name. Self-built function name
SetMyTestObj=Server.CreateObject("TestVBCode.HelloWorld")
MyTestObj.SayHello
%>
7. The results of running the Test.asp file are displayed as follows:
HelloWorld
The above example will open the door to your VB programming world
Let's come together, haha!