FAQ: Property Get, Property Let and Property Set I am not very understanding.

xiaoxiao2021-03-06  105

Main topic: Property Get and Property Let ... I don't understand. Author: WBQC9912115 (sigh in the wind) is: credit value: 82 community: Web development ASP problem points: 20 Reply times: 5 Published: 2004-9-25 9:37:36

Property Get, Property Let and Property Set I am not very understandable.

Please tell me in detail. For example, it is best to thank you!

Reply to: cime63 (return) () Reputation: 100 2004-9-25 9:45:48 Score: 5

<%

'In the Class block, members are declared as Private through the corresponding statement statement (private member, only within the class) or public (public member, can be called within the class).

'The declared Private will only be visible in the Class block. Declare that PUBLIC is not only visible inside the Class block, and it is also visible to the code outside the Class block.

'Didn't use Private or public clearly declared by default as public. The process (SUB or FUNCTION) that is declared as public is declared as a process of publication.

'Public variables will become the properties of the class, just like the properties explicitly declared using the Property Get, Property Let, and Property Set.

The default attributes and methods of the 'class are specified by the default keywords in their declaration.

Class myclass

'// - - Declaration (declaration is defined) Myclass class's class inside (private [private]) variable

Private Strauthor

Private strVersion

Private strexample

'// ------------------------- Define the event ---------------------------------------------------------------------------------------------- --------------- //

'// ---- Class_Initialize () is an initialization event of a class, as long as you start using this class, first trigger the execution of the part.

'The following we will initialize the author and version of this class in this member to display this class on the screen.

Private sub coplass_initialize ()

StrauThor = "Siyuan"

Strversion = "1.0"

Response.write "" Myclass started "

End Sub

'// ---- class_terminate () is an end event of a class. This event is triggered as long as you exit the class.

'Below we will set out the class in this event, it is over the screen.

Private sub coplass_terminate ()

Response.write "

End Sub

'// --------------------------- User's own definition method --------------- ---------------- //

'// ---- This method returns a version information

Public Sub Information ()

Response.write "Coding by maxid_zen @ www.design60s. COM . "END SUB

'// ------------------------- Define the output attribute of the class ------------- ---------------- //

'// - Class-class properties, this property is to initialize the strexample variable

Public property lette set designExample (Byval Strvar)

strexample = strvar

End Property

'// ------------------------- Define the output attribute of the class ------------- ---------------- //

'// ---- Define the properties of the class, this property is returned to a version number

Public property Get Version

Version = strVersion

End Property

'// - Define the properties of the class, this property is the author number of the class

Public property Get Author

Author = strauthor

End Property

'// ---- Define the properties of the class, this property is returned to user-defined information

Public property Get Example

EXAMPLE = strexample

End Property

END CLASS

%>

<%

'// ------- Here is an example using this class

Dim Onenewclass

Set onnenewclass = new myclass

Response.Write "OF:" & oneNewClass.Author & "
"

Response.write version: "& onnenewclass.version & ">"

Onenewclass.sexample = "This is an example of a simple class"

Response.write "User Custom:" & OnenewClass.example & "> "

Onenewclass.information

Set onnenewclass = Nothing

%>

TOP

Reply to: cime63 (return) () Reputation: 100 2004-9-25 9:47:35 Score: 5

Property get statement

In the Class block, the name, parameters, and code of the main body that make up the attribute process used to acquire the value of the value (return).

[Public [default] | property Get Name [(arglist)]

[statements]

[[Set] Name = expression]

[EXIT Property]

[statements]

[[Set] Name = expression]

End Property

parameter

Public

Indicates that the Property GET process can be accessed by other procedures in all scripts.

DEFAULT

Use only with the public keyword, indicating that the properties defined during the Property GET are default attributes for classes. Private

Indicates that the Property GET process is only available to other processes defined in the CLASS block.

Name

The name of the Property GET process; complies with the standard variable naming rules, the difference is only that it can be with the Property LET or Property set process in the same Class block.

arglist

This variable list represents the parameters passed to it when the Property Get process is called. The multiple parameters are separated by commas. The name of each parameter during the Property GET must be the same as the corresponding parameters during the Property LET (if any).

Statements

Any group of statements will be executed in the main body of the Property GET process.

Set

Use the keyword used when the object is used as the return value of the Property GET process.

EXPRESSION

The return value of the Property GET process.

Description

If public or private is not explicitly declared, the Property GET process is default, that is, they are visible to all other processes in the script. The value of local variables during the Property GET is not saved between different process calls.

The Property GET process cannot be defined inside any other process (such as function or printright.

The Exit Property statement will result in immediate exiting from the Property GET. The program will continue to perform the program after the statement to call the Property GET process. The EXIT Property statement can appear anywhere in the Property GET, and the number of times is not limited.

Similar to the SUB and Property Let processes, the Property GET process is a process of accepting parameters, and a series of statements can be performed, and the values ​​of the parameters are performed. However, unlike the SUB and Property LET, the Property GET process can be used for the right side of the expression, with the value of returning the attribute with the same manner as using the function or attribute name.

TOP

Reply to: Ryuginka (except for me who dares to use the real name: Liu Yinhua) () Reputation: 95 2004-9-25 9:47:46 Score: 0

OK

TOP

Reply to: cime63 (return) () Reputation: 100 2004-9-25 9:48:13 Score: 5

Property Let statement

In the Class block, the declaration name, parameters, and code, etc., which constitute the main body of the Property process of assignment (set).

[Public | private] Property Let Name

[arglist,] value

)

[statement]

[EXIT Property]

[statement]

End Property

parameter

Public

Indicates that the Property LET process can be accessed by all other processes in all scripts.

Private

Indicates that the Property LET process can only be accessed by other procedures within the Class block defined.

Name

The name of the Property Let process; compliance with standard variable naming rules, the difference is that its name can be the same as the Property GET or Property SET process in the same Class block.

arglist

The variable list represents the parameters that are passed to the Property LET process during the call. A comma is separated between multiple parameters. The name of each parameter of the Property LET process must be the same as the corresponding parameters during the Property GET. In addition, the Parameters of the Property Let process are more than one in the corresponding Property GET process. This parameter is a value given to the property. Value

This variable contains a value to give attributes. When the process is called, the parameter will appear on the right side of the calling expression.

Statement

Any group of statements will be executed within the main body of the Property LET process.

Note that each Property Let statement must define at least one parameter for the defined attribute. This parameter (the last parameter when there are multiple parameters) contains the value to give attributes when the Property Let statement is called. This parameter is called Value in the previous grammar.

Description

If you are not explicitly specified, the Property LET process is set to public, ie they are visible to all other processes within the script. The value of the local variable during the Property Letter is not saved between different process calls.

The Property Let process cannot be defined inside any other process (such as function or precaty get).

The EXIT Property statement will result in immediate exiting from the Property LET process. The program will continue to execute after the point of calling the Property LET process. The EXIT Property statement can appear anywhere in the Property Letter, and the number of times is not limited.

Similar to the function, the Property LET process is a separate process, which can accept parameters, perform a series of statements, and change the value of the parameters. However, different from the function and the Property GET process is that both return a value, and the Property LET process can only be used on the left side of the attribute assignment expression.

TOP

Reply to: cime63 (return) () Reputation: 100 2004-9-25 9:48:30 Score: 5

Property SET statement

In the Class block, the name, parameters, and code are declared, which constitutes the main body of the Property process that will be set to the object.

[Public | private] Property Set Name

[arglist,] Reference

)

[statement]

[EXIT Property]

[statement]

End Property

parameter

Public

Indicates that the Property SET process can be accessed by all other procedures in all scripts.

Private

Indicates that the Property SET process can only be accessed by other procedures in the same class block in the state.

Name

The name of the Property SET process; complies with the standard variable naming rules, but the name can be the same as the Property GET or Property LET process in the same Class block.

arglist

Variable lists, represents the parameters passed to it when the Property SET process is called. The multiple parameters are separated by commas. In addition, the Property SET process will always be more than one parameter than its corresponding Property GET process. This more parameters are objects given.

Reference

Variables include object references that are used for object reference assignment.

Statement

Any group of statements that will be executed in the Property SET process body.

Note that each Property SET statement must define at least one parameter for the defined process. When the process defined by the Property SET statement is called, the required parameter (the last parameter when multiple parameters) will provide an actual object reference for the attribute. In the previous grammar, this parameter is referred to as a reference. Description

The Property SET process is set to default public mode unless explicitly specified using public or private, that is, all the other processes in the script are visible. When there is a different process call, local variables in the Property set are not saved.

You cannot define the Property SET process in any other process, such as function or printy let.

The EXIT Property statement will result in immediate exiting from the Property SET process. The program will continue to perform the statement after calling the Property SET process. The number of EXIT PROPERTY statements is unrestricted and can appear anywhere in the ProPerty Set.

Similar to the function, the Property set process is a separate process, which can have several parameters, perform a series of statements, and change the value of the parameters. However, in the process of the function and the Property GET, the functions and processes can return values, and the Property SET process object reference assignment (SET statement) on the left side.

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

New Post(0)