Thursday, July 25, 2013

Functions In VB.Net



The function is one of the procedure used in VB.Net. The Function is used to evaluate/execute one or more statements after the function has been called.

The general syntax is as follows

[Access specifier] Function FunctionName [(ParameterList)] As ReturnType
    [Statements]
End Function


Where,
ü       Access specifier: specifiy the access level of the function; possible values are: Public, Private, Protected, Friend, Protected Friend and information regarding overloading, overriding, sharing, and shadowing.
ü       FunctionName: indicates the name of the function
ü       ParameterList: specifies the list of the parameters
ReturnType: specifies the data type of the variable the function returns

Ex:

Public Function MyCalc () As Integer
    Dim A,B as Integer, C As Integer
   C = A + B
   ReturnC
End Function