Breaking News
You are here: Home / Notes / SEM-4 / .NET PROGRAMMING / Functions in

Functions in




A procedure is a group of statements that together perform a task when called. After the procedure is executed, the control returns to the statement calling the procedure. VB.Net has two types of procedures:

  • Functions
  • Sub procedures or Subs

Functions return a value, whereas Subs do not return a value.

Defining a Function

The Function statement is used to declare the name, parameter and the body of a function. The syntax for the Function statement is:

[Modifiers] Function FunctionName [(ParameterList)] As ReturnType
End Function


  • Modifiers: specify 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


Function FindMax(ByVal num1 As Integer, ByVal num2 As Integer) As Integer
   ' local variable declaration */
   Dim result As Integer
   If (num1 > num2) Then
       result = num1
       result = num2
   End If
   FindMax = result
End Function





Download Paper Solutions from Below Link

About admin

Scroll To Top