Share via


Público (Visual Basic)

Specifies that one or more declared programming elements have no access restrictions.

Comentários

If you are publishing a component or set of components, such as a class library, you usually want the programming elements to be accessible by any code that interoperates with your assembly. To confer such unlimited access on an element, you can declare it with Public.

Public access is the normal level for a programming element when you do not need to limit access to it. Note that the access level of an element declared within an interface, module, class, or structure defaults to Public if you do not declare it otherwise.

Rules

  • Declaration Context. You can use Public only at module, interface, or namespace level. This means the declaration context for a Public element must be a source file, namespace, interface, module, class, or structure, and cannot be a procedure.

Behavior

  • Nível de acesso. Tudo o código pode acessar um módulo, classeou estrutura pode acessar seu Public elementos.

  • Default Access. Local variables inside a procedure default to public access, and you cannot use any access modifiers on them.

  • 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 Public 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

Module Statement

Operator Statement

Property Statement

Structure Statement

Sub Statement

Consulte também

Referência

Protegido (Visual Basic)

Friend (Visual Basic)

Private (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