ASP Component beginner and master series 3

Source: Internet
Author: User

How to use attributes

Open VB6 and create an ActiveX dll project. Change project name to fcom and class name to FC2

Choose> Tools> Add process.

Enter myname in the name, type selection attribute, range selection public, and then OK

Operation again: Enter age in the name, type selection attribute, range selection public, and then OK

Operation again: Enter peopleinfo in the name, type selection function, range selection public, and then OK

 

The Code is as follows:

Option explicit

'The local variable holding the property value can only be used in the class

Private mvarmyname as string

Private mvarage as integer

'Let write attribute (let attribute: This process assigns a value to an attribute .)

Public property let age (byval vdata as integer)

Mvarage = vdata

End Property

'Get read attribute (this process obtains the value of an attribute .)

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. You can write a simple component. Click the menu> File> Generate the fcom. dll file.

OK. The fcom. dll file will appear in the directory.

 

Test

Open visual interdev6.0 and generate an ASP file. Why should I use InterDev? Because it has the code prompt function, it is consistent with the VB IDE environment for easy writing?

 

<% @ Language = VBScript %>

<HTML>

<Body>

<%

Set OBJ = server. Createobject ("fcom. FC2 ")

Dim C

'The let attribute of the component is called here.

OBJ. myname = "tornado"

OBJ. Age = 20

C = obj. leleinfo ()

Response. Write c

'The get attribute of the component is called here.

Response. Write "<br>"

Response. Write obj. myname

Response. Write "<br>"

Response. Write obj. Age

%>

 

</Body>

</Html>

 

Configure the virtual directory and execute the ASP file in IE. The result is as follows:

Name: tornado age: 20
Tornado
20

 

To be continued

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.