End Statement


End Statement

Syntax

     End      End AddHandler     End Class     End Enum     End Function     End Get     End If     End Interface     End Module     End Namespace     End Property     End RaiseEvent     End RemoveHandler     End Select     End Set     End Structure     End Sub     End SyncLock     End Try     End Using     End With     End While 

Description

Ends an application, a procedure, or a block of code.

Usage at a Glance

  • The End statement is used as follows:

    Statement

    Description

    End

    Terminates program execution.

    End AddHandler

    New in 2005. Marks the end of an AddHandler block in a Custom Event definition..

    End Class

    Marks the end of a class definition.

    End Enum

    Marks the end of a series of enumerated constants.

    End Function

    Marks the end of a Function procedure.

    End Get

    Marks the end of a Property Get definition.

    End If

    Marks the end of an If...Then...Else statement.

    End Interface

    Marks the end of an Interface definition.

    End Module

    Marks the end of a code Module.

    End Namespace

    Marks the end of a Namespace definition.

    End Property

    Marks the end of a Property definition.

    End RaiseEvent

    New in 2005. Marks the end of a RaiseEvent block in a Custom Event definition.

    End RemoveHandler

    New in 2005. Marks the end of a RemoveHandler block in a Custom Event definition.

    End Select

    Marks the end of a SelectCase statement.

    End Set

    Marks the end of a Property Set definition.

    End Structure

    Ends the definition of a Structure (user-defined type).

    End Sub

    Marks the end of a Sub procedure.

    End SyncLock

    Terminates synchronization code in a SyncLock block.

    End Try

    Marks the end of a try...Catch...Finally statement.

    End Using

    New in 2005. Marks the end of a Using statement.

    End With

    Marks the end of a With statement.

    End While

    Marks the end of a While statement.


  • When used alone, the End statement wraps calls to the private FileSystem.CloseAllFiles function, as well as to the System.Environment object's Exit method, making it a relatively safe statement for terminating an application. However, it does not release resources not automatically handled by the garbage collector, and it does not automatically call Finalize destructors.

Version Differences

  • In VB 6, the End statement used by itself was to be avoided, since it terminated program execution abruptly without performing normal cleanup operations. In .NET, End is much safer and is not to be avoided.

  • A number of the End statements, such as End Namespace, are new to .NET.

  • The End While statement replaces the VB 6 Wend statement to terminate a While loop.

  • The 2005 version of VB introduces the End Using, End AddHandler, End RaiseEvent, and End RemoveHandler statements.

See Also

Exit Statement




Visual Basic 2005(c) In a Nutshell
Visual Basic 2005 in a Nutshell (In a Nutshell (OReilly))
ISBN: 059610152X
EAN: 2147483647
Year: 2004
Pages: 712

flylib.com © 2008-2017.
If you may any questions please contact us: flylib@qtcs.net