First , we must know Modules and Class in the VB.Net.
Modules:
Modules are VB counterparts to C# static classes.
you don't want to allow inheritance and instantiation, you use a Module.
Class:
A class is a collection of objects of similar type. Once a class is defined, any number of objects can be created which belong to that class.
Methods
A Method is a procedure built into the class. They are a series of statements that are executed when called.
Sub Procedures
Sub procedures are methods which do not return a value. Each time when the Sub procedure is called the statements within it are executed until the matching End Sub is encountered.
Function is a method which returns a value. Functions are used to evaluate data, make calculations or to transform data. Declaring a Function is similar to declaring a Sub procedure. Functions are declared with the Function keyword.
Example call Module function and Class methods
Here , i give a program for get splitting a string using function in VB.net
In vb.Net Function will return a value.
How to call Functions and Methods in the Application?
Modules:
Modules are VB counterparts to C# static classes.
you don't want to allow inheritance and instantiation, you use a Module.
Class:
A class is a collection of objects of similar type. Once a class is defined, any number of objects can be created which belong to that class.
Methods
A Method is a procedure built into the class. They are a series of statements that are executed when called.
Sub Procedures
Sub procedures are methods which do not return a value. Each time when the Sub procedure is called the statements within it are executed until the matching End Sub is encountered.
Function is a method which returns a value. Functions are used to evaluate data, make calculations or to transform data. Declaring a Function is similar to declaring a Sub procedure. Functions are declared with the Function keyword.
Example call Module function and Class methods
Here , i give a program for get splitting a string using function in VB.net
In vb.Net Function will return a value.
Module Module1
Function splittingvalue(ByVal strigs As String, ByVal sr As Char) As String()
Dim st As String() = strigs.Split(New Char() {sr})
Return st
End Function
Function splittingvalue(ByVal strigs As String, ByVal sr As Char) As String()
Dim st As String() = strigs.Split(New Char() {sr})
Return st
End Function
Public Class Class1
Public Shared Sub displaymessage()
MessageBox.Show("Good Luck")
End Sub
End Class
Public Shared Sub displaymessage()
MessageBox.Show("Good Luck")
End Sub
End Class
How to call Functions and Methods in the Application?
Class1.displaymessage() // Method...
Dim result As String() = Module1.splittingvalue("Lakshmi", "k") // Function
Dim conResult = result(0) + result(1)
MessageBox.Show(Convert.ToString(conResult))
Dim result As String() = Module1.splittingvalue("Lakshmi", "k") // Function
Dim conResult = result(0) + result(1)
MessageBox.Show(Convert.ToString(conResult))