ASP component primary entry and exquisite series

zhaozj2021-02-16  101

How to use properties

Open VB6, create a new ActiveX DLL project. The engineering name is modified to FCOM, and the class name is modified to FC2

Click on the menu -> Tool -> Add Procedure

We enter myName, type selection properties in the name, and we choose public, then determine

Opening again: Enter the AGE, type selection properties in the name, and select public, then determine

Opening again: Enter the people in the name, the type selection function, the range selection, then determine

code show as below:

Option expedition

'Keep the local variable of the attribute value, can only be used in the class

Private mvarmyname as string

Private mvarage as integer

'Let write properties (LET property: This process assigns a property.)

Public Property Let Age (Byval VData As Integer)

Mvarage = vdata

End Property

'Get read properties (this process gets 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 people () AS STRING

PEOPLEINFO = "Name:" & mvarmyname & "Age:" & mvarage

END FUNCTION

OK, a simple component is written, click on the menu -> File -> Generate the FCOM.dll file

Determine, there will be an FCOM.dll file in the directory.

test

Open Visual InterDev6.0, generate an ASP file, why use InterDev, because it has code prompt function, consistent with the VB IDE environment, easy to write

<% @ Language = VBScript%>

<%

Set obj = server.createObject ("fcom.fc2")

DIM C

'Calling here is the letas of the component

Obj.myname = "Tornado"

OBJ.AGE = 20

c = obj.peopleinfo ()

Response.write C

'This call is the Get property of the component.

Response.write "
"

Response.write obj.myname

Response.write "
"

Response.write obj.AG

%>

Configure a virtual directory, perform this ASP file in IE, resulting in the following:

Name: Dragon Tornado Age: 20 Tornado 20

Last continued

转载请注明原文地址:https://www.9cbs.com/read-10505.html

New Post(0)