Compartilhar via


WithEvents (Visual Basic)

Specifies that one or more declared member variables refer to an instance of a class that can raise events.

Comentários

When a variable is defined using WithEvents, you can declaratively specify that a method handles the variable's events using the Handles keyword.

You can use WithEvents only at class or module level. This means the declaration context for a WithEvents variable must be a class or module and cannot be a source file, namespace, structure, or procedure.

You cannot use WithEvents on a structure member.

You can declare only individual variables—not arrays—with WithEvents.

Rules

  • Tipos de elemento. Você deve declarar WithEvents variáveis como variáveis de objeto para que eles aceitam instâncias de classe . However, you cannot declare them as Object. You must declare them as the specific class that can raise the events.

The WithEvents modifier can be used in this context: Instrução Dim (Visual Basic)

Consulte também

Referência

Cláusula Handles (Visual Basic)

Outros recursos

Palavras-chave (Visual Basic)

Eventos (Visual Basic)