Search

Wednesday, March 5, 2014
0 comments

Difference between procedure and function

7:28 AMWednesday, March 5, 2014
Procedure
Function
A procedure is a block of code that can't returning a value. You can say it’s a types of function when that doesn’t return the value.

Example.
Module ABC

    Sub Main()
      
        SProcedure()
       
    End Sub
   
    Sub SProcedure()
        Console.WriteLine("dotprogramming.blogspot.com")
    End Sub
   
End Module

A function is a block of code and after running its code returns a value to the calling code.

Example
Module ABC

    Dim a As Integer = 10
    Dim b As Integer = 20
   
    Dim result As Integer

    Sub Main()

        result = Addition(a, b)
        Console.WriteLine(Addition(a, b))
       
    End Sub
   
    Function Addition(ByVal c As Integer, _
                       ByVal d As Integer) As Integer
        Return c+d
    End Function
   
End Module
Procedure are not categorize or you can say it doesn’t divide in parts.
Functions are divide in two parts
1.       Built-in function
2.       User-defined function
Use “Sub” keyword for creating procedure
Use “function” keyword for creating function.
Procedure will execute when action is called
But in case of function you can say it’s a loop.
Protected by Copyscape Online Copyright Protection Software

0 comments :

Post a Comment

 
Toggle Footer
Top