ASP components entry-level and Proficient Series III

Source: Internet
Author: User
Tags integer range
How to use Attributes

Open VB6 and create a new ActiveX DLL project. Project name modified to fcom, class name modified to FC2

Click menu-> Tool-> Add process

We enter myname in the name, type select attribute, range Select public, and then determine

Re-operate: Enter age within the name, type select attribute, scope to select public, and then determine

Re-operation: Enter Peopleinfo in the name, type select function, range Select public, then OK



The code is as follows:

Option Explicit

' Keep the local variable of the property value and use it only in the class

Private Mvarmyname as String

Private Mvarage as Integer

' Let-write property: This procedure assigns a value to a property. )

Public-let-age (ByVal vdata as Integer)

Mvarage = Vdata

End Property

' Get Read property (This procedure gets the value of a property.) )

Public Property Get Age () as Integer

Age = Mvarage

End Property



Public Property Let MyName (ByVal vdata as String)

Mvarmyname = Vdata

End Property



Public Property Get MyName () as String

MyName = Mvarmyname

End Property



Public Function Peopleinfo () as String

Peopleinfo = "Name:" & Mvarmyname & "Age:" & Mvarage

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>

<BODY>

<%

Set Obj=server. CreateObject ("FCOM.FC2")

Dim c

' The Let property of the component is called here

Obj.myname = "Tornado"

Obj. Age =20

C=obj.peopleinfo ()

Response.Write C

' The component's Get property is called here

Response.Write "<br>"

Response.Write Obj.myname

Response.Write "<br>"

Response.Write obj. Age

%>



</BODY>

</HTML>



Configure the virtual directory, in IE to execute this ASP file, the results are as follows:

Name: Tornado Age: 20
Tornado
20



To be Continued



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.