End... Statement |
End End Class End Enum End Function End Get End If End Interface End Module End Namespace End Property End Select End Set End Structure End Sub End SyncLock End Try End With End While
Ends a procedure or a block of code
The End statement is used as follows :
Statement | Description |
---|---|
End | Terminates program execution |
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 | Markes the end of a namespace definition |
End Property | Marks the end of a Property Let , PropertyGet , or Property Set procedure |
End Select | Marks the end of a Select Case statement |
End Set | Marks the end of a Property Set definition |
End Structure | Ends the definition of a structure or user -defined type |
End Sub | Marks the end of a Sub procedure |
End SyncLock | Terminates synchronization code |
End Try | Marks the end of a Try...Catch 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 relatively safe to call to terminate an application. However, it does not release resources not automatically handled by the garbage collector, and does not automatically call the Finalize destructor.
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 VB.NET, End is much safer, and is not to be avoided.
A number of the End ... statements are new to VB.NET. These include End Class (classes are defined in separate CLS files in VB 6), End Get (Property Get statements are terminated with an End Property statement in VB 6), End Interface (interfaces are implemented as virtual base classes in VB 6), End Module (code modules are defined in separate BAS files in VB 6), End Namespace (namespaces do not exist in VB 6), End Set (Property Set and Property Let statements are terminated with an End Property statement in VB 6), End Try (VB 6 does not support structured exception handling), and End While (VB 6 supports the Wend statement to terminate a While loop).
Exit Statement