Compartilhar via


Private (Visual Basic)

Specifies that one or more declared programming elements are accessible only from within their declaration context, including from within any contained types.

Comentários

If a programming element represents proprietary functionality, or contains confidential data, you usually want to limit access to it as strictly as possible. You achieve the maximum limitation by allowing only the module, class, or structure that defines it to access it. To limit access to an element in this way, you can declare it with Private.

Rules

  • Declaration Context. Você pode usar Private somente no nível de módulo . This means the declaration context for a Private element must be a module, class, or structure, and cannot be a source file, namespace, interface, or procedure.

Behavior

  • Nível de acesso. Tudo o código em umcontexto de declaraçãopode acessar seus Private elementos. This includes code within a contained type, such as a nested class or an assignment expression in an enumeration. No code outside of the declaration context can access its Private elements.

  • Modificadores de acesso. The keywords that specify access level are called access modifiers. For a comparison of the access modifiers, see Níveis de acesso em Visual Basic.

The Private modifier can be used in these contexts:

Class Statement

Const Statement

Declare Statement

Delegate Statement

Dim Statement

Enum Statement

Event Statement

Function Statement

Interface Statement

Property Statement

Structure Statement

Sub Statement

Consulte também

Referência

Público (Visual Basic)

Protegido (Visual Basic)

Friend (Visual Basic)

Conceitos

Níveis de acesso em Visual Basic

Procedimentos no Visual Basic

Outros recursos

Estruturas (Visual Basic)

Objetos e Classes no Visual Basic