The Public keyword grants a common access permission to one or more declared programming elements. There are no restrictions on the accessibility of public elements.
The Public keyword is used in the following context:
Class Statement Const Statement Declare Statement Delegate Statement DIM Statement Enum Statement Event Statement Function Statement Interface Statement Module Statement Property Statement Structure Statement Sub statement
2. Private
The Private keyword grants privacy access to one or more declared programming elements. Access to private elements can only occur in the context in which the private element is declared, including members of any nested type, such as from within a nested procedure or within an assignment expression in a nested enumeration. (cannot be used with a module statement)
The Private keyword is used in the following context:
Class Statement Const Statement Declare Statement Delegate Statement DIM Statement Enum Statement Event Statement Function Statement Interface Statement Property Statement Structure Statement Sub statement
3, Protected
The Protected keyword grants protected access to one or more declared programming elements. Protected elements can only be accessed from their own classes or derived classes. Protected Access is not a superset of friend access.
In the same declaration, you can use the Protected keyword in conjunction with the Friend keyword. This combination grants Friend and Protected access to declared elements, so they can be accessed from the same assembly, their own classes, and any derived classes.
The Protected keyword is used in the following context:
Class Statement Const Statement Declare Statement Delegate Statement DIM Statement Enum Statement Event Statement Function Statement Interface Statement Property Statement Structure Statement Sub statement
4, Friend
The Friend keyword grants friend access to one or more of the declared programming elements. Friendly elements can be accessed from the program that contains the declaration and from anywhere else in the same assembly.
The Friend keyword can be used in conjunction with the Protected keyword in the same declaration. This combination grants Friend and Protected access to declared elements, so they can be accessed from the same assembly, their own classes, and any derived classes.
The Friend keyword is used in the following context:
Class Statement Const Statement Declare Statement Delegate Statement DIM Statement Enum Statement Event Statement Function Statement Interface Statement Module Statement Property Statement Structur E Statement Sub statement
5. Static
The static keyword indicates that one or more declared variables are static. Static variables continue to exist after the procedure that declares them terminates and retain their latest values.
The Static keyword is used in the following context: Dim statement
Dim (It is not a modifier)
Use to declare and assign a variable's storage space at the module, class, structure, procedure, or block level. Variables declared with Dim are available to all code within the region that contains the Dim statement. If they are declared in a module, class, or struct (but outside of a procedure), they can be accessed from anywhere in the module, class, or structure. If they are declared in a procedure or block, they can only be accessed from the procedure or block. To specify their accessibility in more detail, include public, Protected, friend, Protected friend, Private, or Static keywords.
The DIM statement can declare the data type of a variable and initialize its contents.
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.