ASP components One of the primary entry-level and proficient series
Source: Internet
Author: User
All along, want to write some components of the application, this time can finally write a bit of their favorite things.
I hope that after learning these tutorials, you can write your own components at will.
Each article may not be related, just write some of the problems that occur during component authoring.
You are welcome to criticize
Environment: Winxp+vb6+sp6+visual interdev6.0
As a first article, let's write a simpler component
The complete function is: Enter two numbers added, return the result of the addition
Open VB6 and create a new ActiveX DLL project. Project name modified to fcom, class name modified to FC1
Click menu-> Tool-> Add process
We enter add in the name, type selection function, range Select public, then OK
Generate the following code, we continue to refine
Option Explicit
Public Function Add (ByVal A as long, ByVal B as long) as long
ADD = a + b
End Function
OK, a simple component is written, click the menu-> file-> generate FCom.dll file
OK, there will be a FCom.dll file in the directory
Test
Open Visual interdev6.0, generate an ASP file, why to use InterDev, because it has code hints, consistent with VB IDE environment, easy to write
<%@ Language=vbscript%>
<HTML>
<HEAD>
<meta name= "generator" content= "Microsoft Visual Studio 6.0" >
</HEAD>
<BODY>
<%
Set Obj=server. CreateObject ("FCOM.FC1")
' The following note, because the function has a return value, can not be written in the following way, or IE will be an error
' Obj. ADD (3,4)
' ERROR type:
' Microsoft VBScript Compiler error (0x800a0414)
' cannot use parentheses when calling a subroutine
'/xml/fc1.asp, line 9, column 12
' Obj. ADD (3,4)
' The following is the correct wording
Dim c
C=obj. ADD (3,4)
Response.Write C
%>
</BODY>
</HTML>
Configure the virtual directory, execute this ASP file in IE, get the result 7
The end of the first article, I wish you all a happy study
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