Table of Contents hide
NB : Use the following –
(I) To open a fresh Console Application or Module :- Open VB .net application first -File Menu – New – Project – Visual Basic – Console Application – ok.
(II) To open a fresh Window Form Application :- Open VB .net application first -File Menu – New – Project – Visual Basic – Window Forms Application – ok.
(III) To add a new module in a Project :-Open the VB .net application first – Project Menu – Add Module – Module – Add.
(IV) To add a new Window Form in a Project :-Open the VB .net application first – Project Menu – Add Window Form – Window Form – Add.
————————–  X  ————————–
Example : A VB .Net Program to display messages differently through a Module using a Console Application.
Imports System

Module Module1

    Sub Main()
        Console.Write("Hello Users")
        Console.Write("Hello India")

        Console.ReadKey()
    End Sub

End Module

Output: Hello UsersHello India

---------------  X  ---------------

Imports System
Module Module1
    Sub Main()
        Console.Write("Hello World Hello India")
        Console.ReadKey()
    End Sub
End Module

Output: Hello World Hello India

---------------  X  ---------------
Imports System

Module Module1

    Sub Main()
        Console.Write("Hello Users")
        Console.Write(" ")
        Console.Write("Hello India")

        Console.ReadKey()
    End Sub

End Module

Output: Hello Users Hello India

---------------  X  ---------------

Imports System

Module Module1

    Sub Main()
        Console.WriteLine("Hello Users")
        Console.Write("Hello India")

        Console.ReadKey()
    End Sub

End Module

Output: 
Hello Users
Hello India

NB: 
When you run the program and if arise an error with this message "Error	1	'Sub Main' was not found in 'ConsoleApplication1.Module1'.	ConsoleApplication1
" then to remove this error, double click on this message and select the option appeared in prompt dialog box and then ok. Error will removed and program working.
Example : A VB .Net Program to display the Declaration and Initialization of different Datatypes in VB .Net through a Module using a Console Application Examples.
Module Module1
    Sub Main()
        Dim x As Integer
        Dim y As String
        Dim z As Char
        Dim m As Single
        Dim p As Boolean
        Dim n As Object

        x = 50
        y = "Welcome"
        z = "A"
        m = 50.03
        p = False
        n = 500032.25648888882

        Console.WriteLine("The Integer value is = " & x)
        Console.WriteLine("The String value is = " & y)
        Console.WriteLine("The Character value is = " & z)
        Console.WriteLine("The Float value is = " & m)
        Console.WriteLine("The Boolean value is = " & p)
        Console.WriteLine("The Object value is = " & n)

        Console.ReadKey()
        
    End Sub
End Module

Output:
The Integer value is = 50
The String value is = Welcome
The Character value is = A
The Float value is = 50.03
The Boolean value is = False
The Object value is = 500032.256488889

---------------  OR  ---------------

Module Module1
    Sub Main()
        Dim x As Integer, y As String, z As Char, m As Single
        Dim p As Boolean
        Dim n As Object

        x = 50
        y = "Welcome"
        z = "A"
        m = 50.03
        p = False
        n = 500032.25648888882

        Console.WriteLine("The Integer value is = " & x)
        Console.WriteLine("The String value is = " & y)
        Console.WriteLine("The Character value is = " & z)
        Console.WriteLine("The Float value is = " & m)
        Console.WriteLine("The Boolean value is = " & p)
        Console.WriteLine("The Object value is = " & n)

        Console.ReadKey()
        
    End Sub
End Module
Example : A VB .Net Program to display the addition result of two static/constant values through a Module using a Console Application Examples.
Module Module1
    Sub Main()
        Dim x, y, z As Integer
        x = 50
        y = 60
        z = x + y

        Console.WriteLine(z)
        Console.WriteLine("The addition result is = " & z)
        Console.WriteLine("The addition result of " & x & " and " & y & " is = " & z)
        Console.ReadKey()
    End Sub
End Module

Output:
110
The addition result is = 110
The addition result of 50 and 60 is = 110

---------------  OR ---------------

Module Module1
    Sub Main()
        Dim x As Integer = 50
        Dim y As Integer = 60
        Dim z As Integer
        z = x + y

        Console.WriteLine("The addition result of " & x & " and " & y & " is = " & z)
        Console.ReadKey()
    End Sub
End Module

Output:
The addition result of 50 and 60 is = 110
Example : A VB .Net Program to display the addition result of two dynamic/user-accepted values through a Module using a Console VB Application.
Module Module1
    Sub Main()
        Dim x, y, z As Integer
        Console.WriteLine("Enter two values")
        x = Console.ReadLine()
        y = Console.ReadLine()
        z = x + y

        Console.WriteLine("The addition result of " & x & " and " & y & " is = " & z)
        Console.WriteLine("First value is = {0}, Second Value is = {1}, Addition result is = {2}", x, y, z)

        Console.ReadKey()
    End Sub
End Module

Output:
Enter two values
45
55
The addition result of 45 and 55 is = 100

---------------  OR ---------------

Module Module1
    Sub Main()
        Dim str As String
        Console.Write("Enter String value = ")
        str = Console.ReadLine()

        Console.WriteLine("The String value is " & str)
        Console.WriteLine("Your Message is: {0}", str)
        Console.ReadKey()
        
    End Sub
End Module

Output:
Enter String value = Welcome
The String value is Welcome
Your Message is: Welcome
Example : A VB .Net Program to display the largest value from two values using an if statement through Module in the Console VB Application.
Imports System

Module Module1
    Sub Main()

        Dim x As Integer = 15
        Dim y As Integer = 33

        If x > y Then
            Console.WriteLine("First value is Larger")
        End If

        If x < y Then
            Console.WriteLine("Second value is Larger")
        End If

        If x = y Then
            Console.WriteLine("Both values are equal/same")
        End If

        Console.WriteLine("press any key to exit from output?")
        Console.ReadKey()
    End Sub

End Module

------------------------  OR  --------------------------

Imports System

Module Module1
    Sub Main()

        Dim x As Integer 
        Dim y As Integer

        'Dim x,y As Integer

        Console.WriteLine("Enter First Integer Value")
        x = Console.ReadLine()

        Console.WriteLine("Enter Second Integer Value")
        y = Console.ReadLine()

        If x > y Then
            Console.WriteLine("First value is Larger")
        End If

        If x < y Then
            Console.WriteLine("Second value is Larger")
        End If

        If x = y Then
            Console.WriteLine("Both values are equal/same")
        End If

        Console.WriteLine("press any key to exit from output?")
        Console.ReadKey()
    End Sub

End Module

------------------------  OR  --------------------------

Imports System

Module Module1
    Sub Main()

        Dim x As Integer 
        Dim y As Integer

        'Dim x,y As Integer

        Console.WriteLine("Enter First Integer Value")
        x = Console.ReadLine()

        Console.WriteLine("Enter Second Integer Value")
        y = Console.ReadLine()

        If x > y Then
            Console.WriteLine("First value {0} is Larger", x)
        End If

        If x < y Then
            Console.WriteLine("Second value {0} is Larger", y)
        End If

        If x = y Then
            Console.WriteLine("Both values {0} and {1} are equal/same",x,y)
        End If

        Console.WriteLine("press any key to exit from output?")
        Console.ReadKey()
    End Sub

End Module 
Example : A VB .Net Program to differentiate & display the Odd and Even value from given/accepted single value using an if-else statement through a Module in the Console Application.
Imports System
Module Module1
    Sub Main()
        Dim val As Integer
        Console.WriteLine("Enter Your Number")
        val = Console.ReadLine()

        If (val Mod 2 = 0) Then
            Console.WriteLine("The given no. is Even")
        Else
            Console.WriteLine("The given no. is Odd")
        End If

        Console.WriteLine("press any key to exit...")
        Console.ReadKey()
    End Sub
End Module

---------------------------------- OR ----------------------------------

Imports System
Module Module1

    Sub Main()
        Dim val As Integer

        Console.WriteLine("Enter Your Number")
        val = Console.ReadLine()

        If (val Mod 2 <> 0) Then
            Console.WriteLine("The given no. is Odd")
        Else
            Console.WriteLine("The given no. is Even")
        End If

        Console.WriteLine("press any key to exit...")
        Console.ReadKey()
    End Sub
End Module

---------------------------------- OR ----------------------------------

Imports System
Module Module1
    Sub Main()
        Dim val As Integer

        Console.WriteLine("Enter Your Number")
        val = Console.ReadLine()

        If (val Mod 2 <> 0) Then
            Console.WriteLine("The given no. {0} is Odd", val)
        Else
            Console.WriteLine("The given no. {0} is Even", val)
        End If

        Console.WriteLine("press any key to exit...")
        Console.ReadKey()
    End Sub
End Module

NB: 
In VB .Net
           <> for Not Equal 
           = for Equal 
           Mod for Remainder Division
Example : A VB .Net Program to display the grade result of an exam as per a given condition from given/accepted single total marks value using if-else if-else statement through Module in Console Application.
Total Marks                       Grade
750-1000                           Distinction
600-749                             First
500-599                             Second
400-499                             Third
<=399                                Unsatisfactory                            
Imports System
Module Module1

    Sub Main()

        Dim tmarks As Integer
       
        Console.WriteLine("Enter Your Total Marks ")
        tmarks = Console.ReadLine()

        If (tmarks >= 750) Then
            Console.WriteLine("Distinction Marks")
        ElseIf (tmarks >= 600) Then
            Console.WriteLine("First division")
        ElseIf (tmarks >= 500) Then
            Console.WriteLine(" Second division")
        ElseIf (tmarks >= 400) Then
            Console.WriteLine("Third division")
        Else
            Console.WriteLine("Unsatisfactory")
        End If

        Console.WriteLine("press any key to exit...")
        Console.ReadKey()

    End Sub
End Module

------------------------  OR  --------------------------

Imports System
Module Module1

    Sub Main()

        Dim tmarks As Single
        Dim msg As String

        Console.WriteLine("Enter Your Total Marks ")
        tmarks = Console.ReadLine()

        If (tmarks >= 750) Then
            msg = "Distinction Marks"
        ElseIf (tmarks >= 600) Then
            msg = "First division"
        ElseIf (tmarks >= 500) Then
            msg = " Second division"
        ElseIf (tmarks >= 400) Then
            msg = "Third division"
        Else
            msg = "Unsatisfactory"
        End If

        Console.WriteLine(msg)
        Console.WriteLine()

        Console.WriteLine("press any key to exit...")
        Console.ReadKey()

    End Sub
End Module

OUTPUT:
Enter Your Total Marks
625
First division

press any key to exit...

------------------------  OR  --------------------------

Imports System
Module Module1

    Sub Main()

        Dim tmarks As Single
        Dim msg As String

        Console.WriteLine("Enter Your Total Marks ")
        tmarks = Console.ReadLine()

        If (tmarks >= 750 And tmarks <= 1000) Then
            msg = "Distinction Marks"
        ElseIf (tmarks >= 600 And tmarks <= 749) Then
            msg = "First division"
        ElseIf (tmarks >= 500 And tmarks <= 599) Then
            msg = " Second division"
        ElseIf (tmarks >= 400 And tmarks <= 499) Then
            msg = "Third division"
        Else
            msg = "Unsatisfactory"
        End If

        Console.WriteLine(msg)
        Console.WriteLine()

        Console.WriteLine("press any key to exit...")
        Console.ReadKey()

    End Sub
End Module
Example : A VB .Net Program Examples to display different output using Select Case statement through Module in Console VB Application.
Imports System
Module Module1

    Sub Main()
        Dim Num As Integer
        Console.WriteLine("Enter Your Choice between 1 to 7 to see the name of day of a week ")
        Console.WriteLine()

        Console.WriteLine("Press 1 to see Monday")
        Console.WriteLine("Press 2 to see Tuesday")
        Console.WriteLine("Press 3 to see Wednesday")
        Console.WriteLine("Press 4 to see Thursday")
        Console.WriteLine("Press 5 to see Friday")
        Console.WriteLine("Press 6 to see Saturday")
        Console.WriteLine("Press 7 to see Sunday")

        Num = Console.ReadLine()

        Select Case Num
            Case 1
                Console.WriteLine("Monday")
            Case 2
                Console.WriteLine("Tuesday")
            Case 3
                Console.WriteLine("Wednesday")
            Case 4
                Console.WriteLine("Thursday")
            Case 5
                Console.WriteLine("Friday")
            Case 6
                Console.WriteLine("Saturday")
            Case 7
                Console.WriteLine("Sunday")
            Case Else
                Console.WriteLine("Entered choice is wrong/Incorrect")
        End Select

        Console.WriteLine("Press any key to exit from output...")
        Console.ReadLine()
    End Sub
End Module

------------------------  OR  ------------------------

Imports System
Module Module1

    Sub Main()

        Dim choice As Char
        Dim num1, num2 As Integer
        Dim result As Single

        Console.WriteLine("Press A or a key from keyboard for Addition result")
        Console.WriteLine("Press S or s key from keyboard for Subtraction result")
        Console.WriteLine("Press M or m key from keyboard for Multiplication")
        Console.WriteLine("Press D or d key from keyboard for Division")
        Console.WriteLine("Press R or r key from keyboard for Remainder Division")

        Console.WriteLine()
        Console.WriteLine("Now Enter your choice")
        choice = Console.ReadLine()

        Console.WriteLine("Now Enter Two values to see the desired result")
        num1 = Console.ReadLine()
        num2 = Console.ReadLine()

        Select Case choice
            Case "A"
            Case "a"
                result = num1 + num2
                Console.WriteLine("Addition result of two number {0} + {1} is = {2}", num1, num2, result)
            Case "S"
            Case "s"
                result = num1 - num2
                Console.WriteLine("Subtraction result of two number {0} - {1} is = {2}", num1, num2, result)
            Case "M"
            Case "m"
                result = num1 * num2
                Console.WriteLine("Multiplication result of two number {0} * {1} is = {2}", num1, num2, result)
            Case "D"
            Case "d"
                result = num1 / num2
                Console.WriteLine("Division result of two number {0} / {1} is = {2}", num1, num2, result)

            Case "R"
            Case "r"
                result = num1 Mod num2
                Console.WriteLine("Division result of two number {0} Mod {1} is = {2}", num1, num2, result)
            Case Else
                Console.WriteLine("Entered choice is incorrect, Try again!")
        End Select

        Console.WriteLine()
        Console.WriteLine("Press any key to exit from output screen...")
        Console.ReadLine()
    End Sub
End Module

------------------------  OR  ------------------------

Imports System
Module Module1

    Sub Main()

        Dim choice As String
        Dim num1, num2 As Integer
        Dim result As Single

        Console.WriteLine("Press Add or ADD or add keys from keyboard for Addition result")
        Console.WriteLine("Press Subtract or SUBTRACT or subtract keys from keyboard for Subtraction result")
        Console.WriteLine("Press Multiply or MULTIPLY or multiply keys from keyboard for Multiplication")
        Console.WriteLine("Press Divide or DIVIDE divide keys from keyboard for Division")

        Console.WriteLine("Now Enter your choice")
        choice = Console.ReadLine()

        Console.WriteLine("Now Enter Two values to see the desired result")
        num1 = Console.ReadLine()
        num2 = Console.ReadLine()

        Select Case choice

            Case "ADD"
            Case "Add"
            Case "add"
                result = num1 + num2
                Console.WriteLine("Addition result of two number {0} + {1} is = {2}", num1, num2, result)

            Case "SUBTRACT"
            Case "Subtract"
            Case "subtract"
                result = num1 - num2
                Console.WriteLine("Subtraction result of two number {0} - {1} is = {2}", num1, num2, result)

            Case "MULTIPLY"
            Case "Multiply"
            Case "multiply"
                result = num1 * num2
                Console.WriteLine("Multiplication result of two number {0} * {1} is = {2}", num1, num2, result)

            Case "DIVIDE"
            Case "Divide"
            Case "divide"
                result = num1 / num2
                Console.WriteLine("Division result of two number {0} / {1} is = {2}", num1, num2, result)
            Case Else
                Console.WriteLine("Entered choice is incorrect, Try again!")

        End Select

        Console.WriteLine("Press any key to exit from output screen...")
        Console.ReadLine()
    End Sub
End Module

------------------------  OR  ------------------------

Imports System
Module Module1

    Sub Main()

        Dim choice As String
        Dim num1, num2 As Integer
        Dim result As Single

        Console.WriteLine("Press Add or ADD or add keys from keyboard for Addition result")
        Console.WriteLine("Press Subtract or SUBTRACT or subtract keys from keyboard for Subtraction result")
        Console.WriteLine("Press Multiply or MULTIPLY or multiply keys from keyboard for Multiplication")
        Console.WriteLine("Press Divide or DIVIDE divide keys from keyboard for Division")

        Console.WriteLine("Now Enter your choice")
        choice = Console.ReadLine()

        Console.WriteLine("Now Enter Two values to see the desired result")
        num1 = Console.ReadLine()
        num2 = Console.ReadLine()

        Select Case choice

            Case "+", "Add", "a", "ADD", "add", "A"
                result = num1 + num2
                Console.WriteLine("Addition result of two number {0} + {1} is = {2}", num1, num2, result)

            Case "SUBTRACT", "Subtract", "subtract", "-", "S", "s", "Sub"
                result = num1 - num2
                Console.WriteLine("Subtraction result of two number {0} - {1} is = {2}", num1, num2, result)

            Case "MULTIPLY", "Multiply", "multiply", "*", "M", "m", "mult"
                result = num1 * num2
                Console.WriteLine("Multiplication result of two number {0} * {1} is = {2}", num1, num2, result)

            Case "DIVIDE", "Divide", "divide", "/", "div", "division", "D", "d"
                result = num1 / num2
                Console.WriteLine("Division result of two number {0} / {1} is = {2}", num1, num2, result)
            Case Else
                Console.WriteLine("Entered choice is incorrect, Try again!")

        End Select

        Console.WriteLine("Press any key to exit from output screen...")
        Console.ReadLine()
    End Sub
End Module

------------------------  OR  ------------------------

Imports System
Module Module1

    Sub Main()

        Dim choice As Char
        Dim num1, num2 As Integer
        Dim result As Single

        Console.WriteLine("Press A or a key from keyboard for Addition result")
        Console.WriteLine("Press S or s key from keyboard for Subtraction result")
        Console.WriteLine("Press M or m key from keyboard for Multiplication")
        Console.WriteLine("Press D or d key from keyboard for Division")
        Console.WriteLine("Press R or r key from keyboard for Remainder Division")
        
        Console.WriteLine()

        Console.WriteLine("Now Enter your choice")

beginning:
        choice = Console.ReadLine()

        If choice = "A" Or choice = "a" Or choice = "S" Or choice = "s" Or choice = "M" Or choice = "m" Or choice = "D" Or choice = "d" Or choice = "R" Or choice = "r" Then
            GoTo process
        Else
            Console.WriteLine("Entered choice is incorrect, Try again, Enter Correct Choice!")
            GoTo beginning
        End If

Process:
        Console.WriteLine("Now Enter Two values to see the desired result")
        num1 = Console.ReadLine()
        num2 = Console.ReadLine()

        Select Case choice
            Case "A"
            Case "a"
                result = num1 + num2
                Console.WriteLine("Addition result of two number {0} + {1} is = {2}", num1, num2, result)
            Case "S"
            Case "s"
                result = num1 - num2
                Console.WriteLine("Subtraction result of two number {0} - {1} is = {2}", num1, num2, result)
            Case "M"
            Case "m"
                result = num1 * num2
                Console.WriteLine("Multiplication result of two number {0} * {1} is = {2}", num1, num2, result)
            Case "D"
            Case "d"
                result = num1 / num2
                Console.WriteLine("Division result of two number {0} / {1} is = {2}", num1, num2, result)

            Case "R"
            Case "r"
                result = num1 Mod num2
                Console.WriteLine("Division result of two number {0} Mod {1} is = {2}", num1, num2, result)
        End Select

        Console.WriteLine()
        Console.WriteLine("Press any key to exit from output screen...")
        Console.ReadLine()

    End Sub
End Module
Example : A VB .Net Program to display Odd and Even results of given/accepted single value using GoTo statement through Module in Console VB Application.
Imports System
Module Module1

    Sub Main()

        Dim num1 As Integer

        Console.WriteLine("Enter your choice")
        num1 = Console.ReadLine()

        If num1 Mod 2 = 0 Then
            GoTo Even
        Else
            GoTo Odd
        End If

Odd:
        Console.WriteLine("The accepted no. is Odd")
        GoTo Terminate

Even:
        Console.WriteLine("The accepted no. is Even")

Terminate:
        Console.WriteLine()
        Console.WriteLine("Press any key to exit from output screen...")
        Console.ReadLine()
    End Sub

End Module

------------------------  OR  ------------------------

Imports System
Module Module1

    Sub Main()

        Dim num1 As Integer

        Console.WriteLine("Enter your choice")
        num1 = Console.ReadLine()
        If num1 Mod 2 <> 0 Then
            GoTo Odd
        Else
            GoTo Even
        End If

Odd:
        Console.WriteLine("The accepted no. is Odd")
        GoTo Terminate

Even:
        Console.WriteLine("The accepted no. is Even")

Terminate:
        Console.WriteLine()
        Console.WriteLine("Press any key to exit from output screen...")
        Console.ReadLine()
    End Sub
End Module
Example : A VB .Net Program to display all the no. from 1 to 10 except 5 using Continue Statement through Module in Console Application.
Imports System
Module Module1
    Sub Main()

        Dim i As Integer

        For i = 1 To 10
            If i = 5 Then
                Continue For
            End If
            Console.WriteLine(i)
        Next

        Console.WriteLine()
        Console.WriteLine("Press any key to exit from output screen...")
        Console.ReadLine()
    End Sub
End Module

Output:
1
2
3
4
6
7
8
9
10

Press any key to exit from output screen...
Example : A VB .Net Program to display all the no. from 1 to 10 except 5,6 and 9 using Continue Statement through Module in Console Application.


Imports System
Module Module1
    Sub Main()

        Dim i As Integer

        For i = 1 To 10
            If i = 5 Or i = 6 Or i = 9 Then
                Continue For
            End If
            Console.WriteLine(i)
        Next

        Console.WriteLine()
        Console.WriteLine("Press any key to exit from output screen...")
        Console.ReadLine()
    End Sub
End Module

Output:
1
2
3
4
7
8
10

Press any key to exit from output screen...

Loading


0 Comments

Leave a Reply

Your email address will not be published. Required fields are marked *

This site uses Akismet to reduce spam. Learn how your comment data is processed.