This documentation is archived and is not being maintained.

9.2.1 Regular Method Declarations

Visual Studio .NET 2003

There are two types of methods: subroutines, which do not return values, and functions, which do. The body and End construct of a method may only be omitted if the method is defined in an interface or has the MustOverride modifier. If no return type is specified on a function and strict semantics are being used, a compile-time error occurs; otherwise the type is implicitly Object or the type of the method's type character. The accessibility domain of the return type and parameter types of a method must be the same as or a superset of the accessibility domain of the method itself.

MethodDeclaration ::= SubDeclaration | FunctionDeclaration
SubDeclaration ::=
   [ Attributes ] [ ProcedureModifier+ ] Sub Identifier
      [ ( [ ParameterList ] ) ] [ HandlesOrImplements ] LineTerminator
   [ Block ]
   [ End Sub LineTerminator ]
FunctionDeclaration ::=
   [ Attributes ] [ ProcedureModifier+ ] Function Identifier
      [ ( [ ParameterList ] ) ] [ As [ Attributes ] TypeName ]
      [ HandlesOrImplements ] LineTerminator
   [ Block ]
   [ End Function LineTerminator ]
ProcedureModifier ::=
   AccessModifier |
   Shadows |
   Shared |
   Overridable |
   NotOverridable |
   MustOverride |
   Overrides |
   Overloads
HandlesOrImplements ::= HandlesClause | ImplementsClause

See Also

9.2.2 External Method Declarations | 9.2.3 Overridable Methods |9.2.4 Shared Methods | 9.2.5 Method Parameters | 9.1 Interface Method Implementation | 9.2.6 Event Handling | 9.2 Methods | 4.6 Accessibility | 4.3.3 Shadowing | Sub Statement (Visual Basic Language Reference) | Sub Procedures (Visual Basic Language Concepts)

Show: