Let's take a look at the Application object.
Previously used Application objects often used for connecting strings for counters and databases
We take counter as an example:
First look at the global.asa file, this is relatively simple
SUB Application_onstart
Application ("counter") = 0
End Sub
script>
then
Open VB6, create a new ActiveX DLL project. The engineering name is modified to FCOM, and the class name is modified to FZ2 reference "Microsoft Active Server Pages Object" object library. Create two component events: OnStartPage and OneundPage Create a reference to the class ScriptingContent in the event onstartpage. Instantiated class scriptingcontent.
code show as below:
Option expedition
'Statement of the object
DIM MyResponse as response
DIM MyRequest as Request
DIM MyApplication AS Application
DIM MyServer As Server
DIM MySession as session
'When the component is created, this event will be triggered.
Public Sub onstartPage (MyScriptingContent as scriptingcontext)
'Instantiation of objects
Set myresponse = myscriptingContent.response
Set myRequest = myscriptingcontent.request
Set myserver = myscriptingContent.server
SET myApplication = myscriptingcontent.application
Set mysession = myscriptingContent.Session
End Sub
'Trigger this event when the component is destroyed
Public Sub OneendPage ()
'Destroying object
Set myresponse = Nothing
Set myRequest = Nothing
Set myserver = Nothing
Set myapplication = Nothing
Set mysession = Nothing
End Sub
'It can be seen that put it in the previous ASP to VB, the way is the same.
Public Sub showcounter ()
DIM INTCOUNTER AS Long
MyApplication.lock
INTCOUNTER = MyApplication ("counter")
INTCOUNTER = INTCOUNTER 1
MyApplication ("counter") = intcounter
myapplication.unlock
MyResponse.Write CSTR (IntCounter)
End Sub
test
Open Visual InterDev6.0 to generate an ASP file
<% @ Language = VBScript%>
<%
DIM OBJ
Set obj = server.createObject ("fcom.fz2")
Obj.showcounter ()
%>
Body>
Html>
Configure a virtual directory, you need to put the global.asa file in the root directory, perform this ASP file in IE, refresh the page, you can see a changing number. Application
The usage tells here.