Seven articles have been written in the preliminary tutorial. There must be some preliminary things to write. I will add them slowly.
Intermediate tutorial content:
This may also be the most important concern: database operations and encapsulation. Use of ASP built-in objects. I will spend a long time to explain these parts. This part requires you to be proficient in using ADO to operate databases and be familiar with ASP's five objects.
Let's take a look at some of the more popular online materials:
As we all know, Asp has five built-in objects: Response, request, server, session, and application. In fact, these five built-in objects are the five ActiveX dll components initialized on the IIS console, since IIS can initialize these five components for ASP, we can also directly reference these components in our ActiveX DLL to implement our programming, that is to say, you can reference these components in the VB Application to access the ASP built-in object.
If you have installed a web server pws4 or IIS4 or above, you have an object library named "Microsoft Active Server Pages object, we can reference this object library in the ActiveX dll application of VB. By referencing this object library, we get an object (class): scriptingcontext, this object is also the core object of our entire article. The relationships in the object library are as follows:
Object Library Class Members
Asptypelibrary scriptingcontext Application
Request
Response
Session
Server
Through the above relationship diagram, we can easily understand the class scriptingcontent.
Here is a specific example:
Open VB6 and create an ActiveX dll project. Change project name to fcom and class name to fz1
Reference the "Microsoft Active Server Pages object" Object Library.
Create two component events: onstartpage and onendpage
Create a reference of the scriptingcontent class in the event onstartpage.
Instantiation class scriptingcontent.
The Code is as follows:
Option explicit
'Object Declaration
Dim myresponse as response
Dim myrequest as request
Dim myapplication as application
Dim myserver as server
Dim mysession as session
'This event is triggered when the component is created.
Public sub onstartpage (myscriptingcontent as scriptingcontext)
'Instantiate the object
Set myresponse = myscriptingcontent. Response
Set myrequest = myscriptingcontent. Request
Set myserver = myscriptingcontent. Server
Set myapplication = myscriptingcontent. Application
Set mysession = myscriptingcontent. Session
Myresponse. Write "ActiveX dll component has been created! "
End sub
'This event is triggered when the component is destroyed.
Public sub onendpage ()
Myresponse. Write "ActiveX dll component has been destroyed! "
'Destroy object
Set myresponse = nothing
Set myrequest = nothing
Set myserver = nothing
Set myapplication = nothing
Set mysession = nothing
End sub
'Define our own component method
Public sub helloworld ()
Myresponse. Write "this is written using ASP built-in objects"
End sub
Test
Open visual interdev6.0 and generate an ASP file
<% @ Language = VBScript %>
<HTML>
<Body>
<%
Set OBJ = server. Createobject ("fcom. fz1 ")
Call obj. helloworld ()
%>
</Body>
</Html>
Configure the virtual directory and execute the ASP file in IE. The result is as follows:
ActiveX dll component has been created! This is the ActiveX dll component written with ASP built-in objects that has been destroyed!