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