Arisisi Original-asp Package DLL tutorial

Source: Internet
Author: User
Tags date object command line date now end iis variable window
Arisisi | tutorial | Original |ASP Package

Arisisi Original video tutorial download address:http://www.alixixi.com/Down/eBook/vb/2007/2007122192320.html

The first time I tried to make a video tutorial, because the computer speed is slow, play time is slow, please understand.

This video explains the most basic VB package ASP code generation DLL production tutorials, suitable for beginners reference. Also I learn VB to make ASP components of the first attempt, video basic success.

Using VB to write ASP component (DLL) sample

Below, will demonstrate how to use VB to make ASP's DLL components ...

1. Start your VB, select the ActiveX DLL icon, and then click on the menu project >> quote, and then
To select from the pop-up references window
Microsoft Active Server Pages Object library.

2. For engineering and class renaming, when called in ASP, it's all depend on it ^_^! Our project name change
For Aspdll, the class name is demo. The method called in ASP is:
Set objreference = Server.CreateObject ("project name. Class Name")
The corresponding code invoked in this example is as follows:
Set objreference = Server.CreateObject ("Aspdll.demo")
The methods called are the same as those commonly used, such as FSO and other components.
Echocardiography, hehe, let's continue ....

3. Then, we began to write code to open the new project we have just opened the window, the first step, a prelude
The variables that we want to use. Mainly in the VB declaration instead of ASP several large object variable name, define this
After several large objects of ASP, we can call like Request,server in ASP environment, etc.
A few of these big objects. (the variable name declared can be exactly the same as the ASP object name) code as follows:

'**********************************************
Private Mys Criptingcontext as S Criptingcontext
Private MyApplication as Application
Private myrequest as Request
Private Myresponse as response
Private MyServer as Server
Private mysession as session
'**********************************************

4. After declaring the variable, we must write the OnStartPage child function in the class. The function is
When a user accesses an ASP file with this component, IIS passes the S Criptingcontext
Give us the VB Component object. This s criptingcontext includes all ASP methods and properties
. This gives us the ability to access all ASP objects. The code is as follows:

'*****************************************************************
Public Sub OnStartPage (Passeds Criptingcontext as S criptingcontext)
Set Mys Criptingcontext = Passeds Criptingcontext
Set MyApplication = Mys criptingcontext.application
Set myrequest = Mys Criptingcontext.request
Set myresponse = Mys Criptingcontext.response
Set myserver = Mys Criptingcontext.server
Set mysession = Mys criptingcontext.session
End Sub
'*****************************************************************

Through the above function, we call this component in ASP, the above several big objects can completely
As usual, we use the same in ASP, for example:

Implement the receive submitted form values in ASP and output the screen:

<%
Formvalue=request.form ("username")
Response.Write ("You submit the username is" &myformvalue& ", welcome you!")
%>

The realization method in VB is:

Formvalue=myrequest.form ("username")
Myresponse.write ("You submit the username is" &myformvalue& ", welcome you!")

5. Relative to the OnStartPage function, we also write a close OnStartPage object
OnEndPage function, the code is as follows:

'*********************************
Public Sub OnEndPage ()
Set Mys Criptingcontext = Nothing
Set MyApplication = Nothing
Set myrequest = Nothing
Set myresponse = Nothing
Set MyServer = Nothing
Set mysession = Nothing
End Sub
'********************************

6. By writing the above code, we have an environment for writing ASP component instances in VB,
Now, I'm going to try to write two functions that are basically similar to the ASP, that is, the key parts are
Here, you can completely put all of your ASP source code here ...

First write the simplest output screen information function:
'********************************************
Public Sub Welcomeinfo ()
Myresponse.write ("Arisisi _web Development, Welcome to visit www.alixixi.com!")
End Sub
'********************************************

Then write a function with the parameter pass and display now time:
'**********************************
Public Sub SetInfo (content as String)
Myresponse.write content & "<br>"
Myresponse.write "Present time is:" & Now ()
End Sub
'**********************************

Through the above example of ASP code, you will find in fact this and the ASP source basically no difference ^_^

7. Well, the entire class was written, and we started packing and packaging into DLLs. We'll save the project,
Here we save to E:\vbdll, then select the file on the menu >> generate Aspdll.dll, very
The fast DLL component is encapsulated and generated.

8. After generating the DLL file, we started debugging and using. Enter CMD in system run bar, enter DOS
Command line status, we want to register the DLL component just generated, the registration method is can be entered directly
regsvr32 e:\vbdll\aspdll.dll, for easy installation, you can also write a batch
File, here are not a few examples ... OK, registration is successful!

9. After the DLL component has been registered, we write a
ASP file for debugging. The code is as follows:

<%
Set Redll = Server.CreateObject ("Aspdll.demo")
Redll.welcomeinfo
Response.Write "Redll.setinfo ("Pass parameters to the server component and return the value and current date now ()!")
Response.Write "Set Redll = Nothing
%>
Open this file in IIS and the screen displays:

Arisisi _web Development, Welcome to visit www.alixixi.com!
------------------------------------------------------------
Pass parameters to the server component and return the value and current date now ()!
Now the time is: xxxx-xx-xx-xx:xx:xx



Related Article

Contact Us

The content source of this page is from Internet, which doesn't represent Alibaba Cloud's opinion; products and services mentioned on that page don't have any relationship with Alibaba Cloud. If the content of the page makes you feel confusing, please write us an email, we will handle the problem within 5 days after receiving your email.

If you find any instances of plagiarism from the community, please send an email to: info-contact@alibabacloud.com and provide relevant evidence. A staff member will contact you within 5 working days.

A Free Trial That Lets You Build Big!

Start building with 50+ products and up to 12 months usage for Elastic Compute Service

  • Sales Support

    1 on 1 presale consultation

  • After-Sales Support

    24/7 Technical Support 6 Free Tickets per Quarter Faster Response

  • Alibaba Cloud offers highly flexible support services tailored to meet your exact needs.