.NET Tutorials, Forums, Interview Questions And Answers
Welcome :Guest
Sign In
Win Surprise Gifts!!!

Top 5 Contributors of the Month
Sandeep Singh

Home >> Code Snippets >> Visual Studio >> Post New Resource Bookmark and Share   

 Subscribe to Code Snippets

Use Modules and Class method in the VB.Net

Posted By:Narayanan       Posted Date: August 20, 2012    Points: 40    Category: Visual Studio    URL: http://www.dotnetspark.com  

Here , I will explain Module,Class and Sub Procedures in VB.Net

First , we must know Modules and Class in the VB.Net.
Modules are VB counterparts to C# static classes.
you don't want to allow inheritance and instantiation, you use a Module.
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.
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

Public Class Class1

    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)


Further Readings:


No response found. Be the first to respond this post

Post Comment

You must Sign In To post reply
Find More code samples in C#, ASP.Net, Vb.Net and more Here

Hall of Fame    Twitter   Terms of Service    Privacy Policy    Contact Us    Archives   Tell A Friend