Difference between procedure and function

March 05, 2014 0 Comments

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.

Module ABC

    Sub Main()
    End Sub
    Sub SProcedure()
    End Sub
End Module

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

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.

Jacob Lefore

Some say he’s half man half fish, others say he’s more of a seventy/thirty split. Either way he’s a fishy bastard. Google