Partilhar via


Outras estruturas de controle (Visual Basic)

Visual Basic provides control structures that help you dispose of a resource or reduce the number of times you have to repeat an object reference.

Using...End Using Construction

The Using...End Using construction establishes a statement block within which you make use of a resource such as a SQL connection. You can optionally acquire the resource with the Using statement. When you exit the Using block, Visual Basic automatically disposes of the resource so that it is available for other code to use. The resource must be local and disposable. For more information, see Instrução Using (Visual Basic).

With...End With Construction

The With...End With construction lets you specify an object reference once and then run a series of statements that access its members. This can simplify your code and improve performance because Visual Basic does not have to re-establish the reference for each statement that accesses it. For more information, see Declaração With...End With (Visual Basic).

Consulte também

Tarefas

Como: Transferir controle para fora de uma estrutura de controle (Visual Basic)

Referência

Instrução Using (Visual Basic)

Declaração With...End With (Visual Basic)

Conceitos

Estruturas de decisão (Visual Basic)

Estruturas de loop (Visual Basic)

Estruturas de controle aninhado (Visual Basic)

Outros recursos

Fluxo de controle no Visual Basic