Last post Apr 04, 2008 05:38 PM by jimmy q
Apr 04, 2008 05:22 PM|maxmax|LINK
I am developing asp.net web application, in which I will have to use Functin() and subroutine()
show me how funciton() and subroutine() are different than each other. I know that funciton returns value and subroutine dont return value.
show me perferct example of differece between both. show me little demo if you can please!
show me that at what points subroutins different from functions()
I know that we use subroutine to different task, show me what kind of tasks
Apr 04, 2008 05:38 PM|jimmy q|LINK
the only difference between subs and functions as you mentioned are subs do not return data and functions do.
So a sub is like a VOID function in C/C++/C#.
A function may look like this
Private Function Sum(byval num1 as Integer, byval num2 as Integer) As Integer
Return num 1 + num2
Notice how after the method declaration there is the As Integer, this means the Sum function will be returning a value of type int to the caller. And inside the code you can see the Return value
The caller of this code will look like this if it is within the same class
dim i as Integer = Sum(1, 2)
A sub does not return anything so it may look like this
Private Sub Sum(byval num1 as Integer, byval num2 as Integer)
'do some actions
So the main differences are there is no AS TYPE at the end of the declaration and within the routine there it does not return any thing back to the caller.
The calling code in the same class would look like this