Functions in VB.Net ?


In Vb.net we use procedure in place of function. Procedure is a group of statements which combined together perform a task.

VB.net has two types of procedure


  • Functions 
  • Sub Procedure or Subs


Funcion returns a value where as sub are non- return type procedure.

Function 

Example

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
   Else
       result = num2
   End If
   FindMax = result
End Function


Sub Procedure Or Sub's

Example

   Sub CalculatePay(ByVal hours As Double, ByVal wage As Decimal)
      'local variable declaration
      Dim pay As Double
      pay = hours * wage
      Console.WriteLine("Total Pay: {0:C}", pay)
   End Sub

Please Subscribe or Comment!! if you need any other details please comment below. 

Comments

Popular posts from this blog

Installing and using LESS.(PART- 3)

How to use lamda expression for updating using LINQ

Difference between Less and CSS ?