Difference Between Functions and Sub Routine in VB.Net 2019 Best Practices
4K views
·
Dec 11, 2021
Difference Between Functions and Sub Routine in VB.Net 2019 Best Practices
This tutorial will teach you about the Difference Between Functions and Subs in VB.NET With Examples.
A procedure is a method that performs a task when it’s called. There are two types of procedures in VB.Net and they are:
Functions – return a value
Sub procedures or Subs – do not return a value
What is a Function? The Function statement is composed of the name, parameter and the body of a function.
This is the syntax in performing the Function statement:
[Modifiers] Function FunctionName [(ParameterList)] As ReturnType
Statements…….
End Function
Where,
Modifiers: it specifies the access level of the function and its values are:
Public, Private, Protected, Friend, Protected Friend, and information concerning overriding overloading shadowing and sharing.
FunctionName: point out the name of the function
parameter list: identifies the list of the parameters
ReturnType: identifies the data type of the variable the function returns
In Visual Basic, a Sub procedure is a series of statements composed by the Sub and End Sub statements. It performs a task that returns control to the calling code, but it does not return any value. it is also used to declare the name, parameter and the body of a subprocedure.
This is the syntax in declaring a parameter in the parameter list:
[Optional] [ByVal | ByRef] [ParamArray] parameter name As datatype
You can also visit this site for the advanced tutorial in the declaring parameter list
Follow the Tutorial here. https://itsourcecode.com/free-projects/vb-net/functions-subs-vb-net/
Show More
Show LessComments
loading text loading
loading text loading
loading text
loading text loading
loading text
loading text loading
loading text
loading text loading
loading text