0% found this document useful (0 votes)
6 views

Vb.net Program

The document outlines a series of programming examples in VB.NET, covering various concepts such as basic input/output, arithmetic operations, conditional statements, loops, and data types. Each section includes a program that demonstrates the specific concept, along with its corresponding code and expected output. The document serves as a comprehensive guide for beginners to learn and understand fundamental programming principles in VB.NET.

Uploaded by

sdgamerz48
Copyright
© © All Rights Reserved
Available Formats
Download as PDF, TXT or read online on Scribd
0% found this document useful (0 votes)
6 views

Vb.net Program

The document outlines a series of programming examples in VB.NET, covering various concepts such as basic input/output, arithmetic operations, conditional statements, loops, and data types. Each section includes a program that demonstrates the specific concept, along with its corresponding code and expected output. The document serves as a comprehensive guide for beginners to learn and understand fundamental programming principles in VB.NET.

Uploaded by

sdgamerz48
Copyright
© © All Rights Reserved
Available Formats
Download as PDF, TXT or read online on Scribd
You are on page 1/ 123

INDEX

1 Program to Demonstrate simple Hello World.

2 Program to Demonstrate Add Two Numbers

3 Program to Demonstrate Variable Declaration

4 Program to Demonstrate Variable Form User

5 Program to Demonstrate Use of Local variable

6 Program to Demonstrate Arithmetical Operators

7 Program to Demonstrate Comparision Operators

8 Program to Demonstrate Logical Bitwise


Operators
9 Program to Demonstrate Bit Shift Operators

10 Program to Demonstrate Assignment Operators

11 Program to Demonstrate Concatenation


Operators
12 Program to Demonstrate Data Types

13 Program to Demonstrate If Condition

14 Program to Demonstrate If Then Else Condition

15 Program to Demonstrate ElseIf Condition

16 Program to Demonstrate If Then ElseIf Condition


17 Program to Demonstrate If Condition in Form
18 Program to Demonstrate If Then Else Condition
in Form
19 Program to Demonstrate ElseIf Condition in
Form
20 Program to Demonstrate NestedIf Condition in
Form
21 Program to Demonstrate Switch Condition in
Form
22 Program to Demonstrate For Next Loop

23 Program to Demonstrate Do Loop

24 Program to Demonstrate Do While Loop

25 Program to Create Mathematical Table

26 Program to find even and odd numbers


Using While Loop
27 Program to find First N Natural Numbers

28 Program to Demonstrate Arrays

29 Program to Demonstrate Arrays Numbers

30 Program to Demonstrate 2D Arrays

31 Program to Demonstrate Arrays Class

32 Program to Demonstrate Sub Procedure

33 Program to find Maximum among two numbers


using functions
34 Program to find factorial of a number using
recursion
35 Program to swap two numbers as passing
argument by Value
36 Program to Swap two numbers as passing
arguments by Reference
37 Program to enter students' detail with class and
objects
38 Program to Demonstrate Inheritance

39 Program to Demonstrate Encapsulation

40 Program to Create Mathematical and Scientific


calculator
41 Program to make registration form with ADO.Net

42 Program to make Login form with ADO.Net

43 Program to create a web form with asp.net


Program to Demonstrate simple Hello World.

Imports System
Module Program
Sub Main(args As String())
Console.WriteLine("Hello World!")
End Sub
End Module

OUTPUT
Program to Demonstrate Add Two Numbers

Imports System
Module Addition
Sub Main()
Dim Num1, Num2, sum As Integer
Console.WriteLine("Enter the first Number :")
Num1 = Console.ReadLine()
Console.WriteLine("Enter the second Number :")
Num2 = Console.ReadLine()
sum = Num1 + Num2
Console.WriteLine("The sum is :" & sum)
Console.ReadLine()
End Sub
End Module
Program to Demonstrate Variable Declaration.

Imports System

Module Program
Sub Main()
Dim intData As Integer
Dim CharData As Char
Dim strData As String
Dim dblData As Double
Dim single_data As Single
intData = 10
CharData = "A"
strData = " VB.NET is a Programming Language."
dblData = 4567.676
single_data = 23.08

Console.WriteLine(" Value of intData is: {0}",


intData)
Console.WriteLine(" Value of CharData is: {0}",
CharData)
Console.WriteLine(" Value of strData is: {0}",
strData)
Console.WriteLine(" Value of dblData is: {0}",
dblData)
Console.WriteLine(" Value of single_data is: {0}",
single_data)

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


Console.ReadLine()
End Sub
End Module

OUTPUT
Program to Demonstrate Variable Form User.

Imports System

Module Program
Sub Main()
Dim num As Integer
Dim name As String
Dim age As Double
Console.WriteLine("Enter your favourite
Number:")
num = Console.ReadLine()
Console.WriteLine("Write your Good name:")
name = Console.ReadLine()
Console.WriteLine("What is your age:")
age = Console.ReadLine()
Console.WriteLine("Your Favourite number
is {0}", num)
Console.WriteLine("Your Good name is {0}",
name)
Console.WriteLine("Your age is {0}", age)
Console.ReadKey()
End Sub

End Module

OUTPUT
Program to Demonstrate Use of Local variable.

Imports System
Module Program
Sub Main()
Console.WriteLine("Hello User!")
Console.WriteLine(" Scope of local varibale within a
function")
local()
local2()
Console.WriteLine("press any key to exit...")
Console.ReadKey()
End Sub
Sub local()
Dim X As Integer
' declaration of local variable
X = 50
Console.WriteLine(" Value of Local value X is {0}", X)

End Sub
Sub local2()
Dim X As String
' scope of local variable within a function
X = "60"
Console.WriteLine(" Value of X is {0}", X)
End Sub
End Module

OUTPUT
Program to Demonstrate Arithmetical Operators.
Imports System
Imports System.Security.Cryptography.X509Certificates
Module Arthmeticaloperators
Sub Main()
Dim a, b, c As Integer
Dim p As Double = 2
Console.WriteLine(" Enter the value of a:")
a = Console.ReadLine()
Console.WriteLine("Enter the value of b:")
b = Console.ReadLine

c=a +b
Console.WriteLine("The sum of a+b is {0}", c)

c=a -b
Console.WriteLine("The difference of a-b is {0}", c)

c=a *b
Console.WriteLine("The Product of a*b is {0}", c)

c=a /b
Console.WriteLine("The quotient of a\b is{0}", c)

c = a Mod b
Console.WriteLine("The Modolus of a Mod b is {0}", c)

c=a ^p
Console.WriteLine("The power of a^p is {0}", c)
Console.WriteLine("Preas any key to exit")
Console.ReadKey()
End Sub
End Module

OUTPUT
Program to Demonstrate Comparision Operators.
Imports System
Module comparision_operators
Sub Main()
Dim A As Integer
Dim B As Integer
Dim Result, obj1, obj2 As Object
Dim str1, str2 As String
Console.WriteLine("Enter the value of A: ")
A = Console.ReadLine()
Console.WriteLine("Enter the value of B: ")
B = Console.ReadLine()
Console.WriteLine("Enter the value of obj1: ")
obj1 = Console.ReadLine()
Console.WriteLine("Enter the value of obj2: ")
obj2 = Console.ReadLine()
Console.WriteLine("Enter the value of str1: ")
str1 = Console.ReadLine()
Console.WriteLine("Enter the value of str2: ")
str2 = Console.ReadLine()
Console.WriteLine(" Output of A > B is {0}", A > B)
Console.WriteLine(" Output of A < B is {0}", A < B)
Console.WriteLine(" Output of A = B is {0}", A = B)
Console.WriteLine(" Output of A <> B is {0}", A <> B)
Console.WriteLine(" Output of A >= B is {0}", A >= B)
Console.WriteLine(" Output of A <= B is {0}", A <= B)
Result = obj1 Is obj2
Console.WriteLine(" Output of obj Is obj2 is {0}", Result)
Result = obj1 IsNot obj2
Console.WriteLine(" Output of obj IsNot obj2 is {0}",
Result)
Result = str1 Like str2
Console.WriteLine(" Output of str Like str2 is {0}", Result)
Console.WriteLine(" Press any key to exit...")
Console.ReadKey()
End Sub
End Module
Program to Demonstrate Logical Bitwise Operators.

Imports System
Imports System.Collections.Specialized
Module Logical_Bitwise
Sub Main()
Dim A, B, Result As Boolean
Console.WriteLine("Enter the value fo A: ")
A = Console.ReadLine()
Console.WriteLine("Ente the value for B: ")
B = Console.ReadLine()

Result = A And B
Console.WriteLine("And operator{0}", Result)

Result = A Or B
Console.WriteLine("Or Operator{0}", Result)

Result = Not A
Console.WriteLine("Not of A{0}", Result)

Result = Not B
Console.WriteLine("Not of B{0}", Result)
Result = A Xor B
Console.WriteLine("Xor operator{0}", Result)

Result = A AndAlso B
Console.WriteLine("AndAlso Operator{0}", Result)

Result = A OrElse B
Console.WriteLine("OrElse Operator{0}", Result)

Console.WriteLine("Press any Key to exit")


Console.ReadKey()
End Sub
End Module
Program to Demonstrate Bit Shift Operators.

Imports System
Module Bit_shift_operator
Sub Main()
Dim X, Y, Z As Double
Console.WriteLine("Enter value of X: ")
X = Console.ReadLine()
Console.WriteLine("Enter value of y: ")
Y = Console.ReadLine()
Z = X And Y
Console.WriteLine("And operator is {0}", Z)
Z = X Or Y
Console.WriteLine("Or operator is {0}", Z)

Z = X Xor Y
Console.WriteLine("Xor operator is {0}", Z)

Z = Not X
Console.WriteLine("Not of X is {0}", Z)

Z = Not Y
Console.WriteLine("Not of Y is {0}", Z)
Console.WriteLine("The left bit shift operaator
X<<1={0}", X << 1)
Console.WriteLine("The lift shift operator
Y<<1={0}", Y << 1)
Console.WriteLine("The right shift operator
X>>1={0}", X >> 1)
Console.WriteLine("The right shift operator
Y>>1={0}", Y >> 1)

Console.WriteLine("Press any key to exit")


Console.ReadKey()
End Sub
End Module
Program to Demonstrate Assignment Operators.

Imports System
Module Program
Sub Main()
Dim A, B, c As Integer
c=2
Dim Str1, Str2 As String
Console.WriteLine("Enter value for A: ")
A = Console.ReadLine()
Console.WriteLine("Enter Str1: ")
Str1 = Console.ReadLine()
Console.WriteLine("Enter Str2: ")
Str2 = Console.ReadLine()
B=A
Console.WriteLine("Assign Value of A to B is
B={0}", B)
B += A
Console.WriteLine("Add and assign value of A to B
is B={0}", B)
B -= A
Console.WriteLine("Subtract and assign value of A
to B is B={0}", B)
B *= A
Console.WriteLine("Multiply and aasign value of A
to B is B={0}", B)
B \= A
Console.WriteLine("Divide and assighn value of A
to B is B={0}", B)
B ^= c
Console.WriteLine("Raise the power C to B is
B={0}", B)
Str1 &= Str2
Console.WriteLine("Conatenate string Str1 and
Str2{0}", Str1)
Console.WriteLine("Press any key to exit")
Console.ReadKey()
End Sub
End Module
OUTPUT
Program to Demonstrate Concatenation Operators.

Imports System
Module Program
Sub Main()
Dim str, str2, str3, str4, result, result2 As String
Console.WriteLine("Write str1:")
str = Console.ReadLine()
Console.WriteLine("Write str2:")
str2 = Console.ReadLine()
Console.WriteLine("Write str3:")
str3 = Console.ReadLine()
Console.WriteLine("Write str4:")
str4 = Console.ReadLine()

result = str & str2


Console.WriteLine(" Result = str & str2 gives =
{0}", result)
result2 = str + str2 + str3 + str4
Console.WriteLine(" Result = str + str2 + str3 +str4
gives = {0}", result2.ToString)
Console.ReadLine()
End Sub
End Module
OUTPUT
Program to Demonstrate Data Types.

Imports System

Module Data_Types
Sub Main()
Console.WriteLine("This Program is developed to
show different Data types in VB.NET")
Dim Str As String
Dim get_date As Date
Dim c As Char
Dim Num As Byte
Dim Num1 As Single
Dim Num2 As Double
Str = "HELLO AND WELLCOME TO MY PROGRAM"
c = "A"
Num = 1
Console.WriteLine("Enter Today's date")
get_date = Console.ReadLine()
Console.WriteLine("Enter value for Num1:")
Num1 = Console.ReadLine()
Console.WriteLine("Enter value for Num2:")
Num2 = Console.ReadLine()
Console.WriteLine("String MSG is:{0} ", Str)
Console.WriteLine("Date:{0}", get_date)
Console.WriteLine("character is:{0}", c)
Console.WriteLine("Byte is:{0}", Num)
Console.WriteLine("Single is:{0}", Num1)
Console.WriteLine("Double is:{0}", Num2)
Console.WriteLine("Press any key to exit")
Console.ReadKey()
End Sub
End Module

OUTPUT
Program to Demonstrate If Condition.

Imports System
Module If_condition
Sub Main()
Dim a As Integer
Console.WriteLine("This is an if condition
program")
Console.WriteLine("Enter the value of A ")
a = Console.ReadLine
If (a > 8) Then
Console.WriteLine("a is greater")
End If
Console.WriteLine("Press any key to exit")
End Sub
End Module
Program to Demonstrate If Then Else Condition.

Imports System
Module Program
Sub Main()
Dim A As Integer
A = 30
Console.WriteLine("This is an IF THEN ELSE
PROGRAM")
Console.WriteLine("Enter the value of A ")
A = Console.ReadLine
If (A < 21) Then
Console.WriteLine("A is greater")
Else
Console.WriteLine("A is not greatest")
End If
Console.ReadKey()
End Sub
End Module
Program to Demonstrate If Then Else Condition.
Imports System
Module Program
Sub Main()
Dim A As Integer
A = 30
Console.WriteLine("This is an IF THEN ELSE
PROGRAM")
Console.WriteLine("Enter the value of A ")
A = Console.ReadLine
If (A < 21) Then
Console.WriteLine("A is greater")
Else
Console.WriteLine("A is not greatest")
End If
Console.ReadKey()
End Sub
End Module
OUTPUT
Program to Demonstrate ElseIf Condition.

Imports System
Module elseif_statement
Sub Main()
Console.WriteLine("This is an elseif conditional
statement program")
Dim a, b, c As Integer
a = 10
b = 20
c = 30
If (a > b) Then
If (a > c) Then
Console.WriteLine("a is greatest")
Else
Console.WriteLine("c is greatet")
End If
Else
If (b > c) Then
Console.WriteLine("b is greatest")

Else
Console.WriteLine("c is greatest")
End If
End If
Console.WriteLine("Press any key to exit")
Console.ReadKey()

End Sub
End Module

OUTPUT
Program to Demonstrate If Then ElseIf Condition.

Imports System
Imports System.Reflection.PortableExecutable
Module If_elseif
Sub Main()
Dim Maths, English, SocialScience, Science,
Hindi, per As Integer
Console.WriteLine("This program is to
demonstrate If then Elseif statement")
Console.WriteLine("Enter the marks of student in
Five subjects:")
Maths = Console.ReadLine()
English = Console.ReadLine()
SocialScience = Console.ReadLine()
Science = Console.ReadLine()
Hindi = Console.ReadLine()
per = (Maths + English + SocialScience + Science + Hindi) / 5

If (per >= 90) Then


Console.WriteLine("Pass with position")
ElseIf (per >= 80) Then
Console.WriteLine("Pass with Distintion")
ElseIf (per >= 70) Then
Console.WriteLine("Pass with First Division")
ElseIf (per >= 60) Then
Console.WriteLine("Pass with Second Division")
ElseIf (per >= 50) Then
Console.WriteLine("Promoted Pass")
Else
Console.WriteLine("Failed")
End If
Console.WriteLine("Press any key to exit")
Console.ReadKey()
End Sub
End Module

OUTPUT
Program to Demonstrate If Condition in Form.

Public Class Form1


Private Sub Button1_Click(sender As Object, e As
EventArgs) Handles Button1.Click
Dim Num As Integer
Num = 20
If (Num > 0) Then
MsgBox("Number is positive")
Else
MsgBox("Number is Negative")
End If
End Sub
End Class
OUTPUT
Program to Demonstrate If Then Else Condition in
Form.

Public Class Form1


Private Sub Button1_Click(sender As Object, e As
EventArgs) Handles Button1.Click
Dim N1, N2 As Double
N1 = 20
N2 = 30
If (N1 > N2) Then
MsgBox("N1 is greater than N2")
Else
MsgBox("N1 is smaller than N2")
End If
End Sub
End Class
OUTPUT
Program to Demonstrate ElseIf Condition in Form.

Public Class Form1


Private Sub Button1_Click(sender As Object, e As
EventArgs) Handles Button1.Click
Dim N1 As Integer = 20
Dim N2 As Integer = 15
Dim N3 As Integer = 30
If (N1 > N2 And N1 > N3) Then
MsgBox("N1 is greatest of all Numbers")
End If
If (N2 > N1 And N2 > N3) Then
MsgBox("N2 is greateest of all Numbers")
End If
If (N3 > N2 And N3 > N1) Then
MsgBox("N3 is greatest of all Numbers")
End If
End Sub
End Class
OUTPUT
Program to Demonstrate NestedIf Condition in Form.

Public Class Form1


Private Sub Button1_Click(sender As Object, e As
EventArgs) Handles Button1.Click
Dim N1, N2, N3 As Integer
N1 = 30
N2 = 25
N3 = 2
If (N1 > N2) Then
If (N1 > N3) Then
MsgBox("N1 is greatest")
Else
MsgBox("N3 is greatest")
End If
Else
If (N2 > N1) Then
If (N2 > N1) Then
MsgBox("N2 is greatest")
Else
MsgBox("N3 is greatest")
End If
End If
End If
End Sub
End Class

OUTPUT
Program to Demonstrate Switch Condition in Form.

Public Class Form1


Private Sub Button1_Click(sender As Object, e As
EventArgs) Handles Button1.Click
Dim Num As Integer
Num = 1000
Select Case Num
Case Is > 30
MsgBox("Num is greater than 30 ")
Case Is > 40
MsgBox("Num is greater than 40")
Case Is > 50
MsgBox("Num is greater than 50")
Case Else
MsgBox("Wrong entry")

End Select

End Sub
End Class
OUTPUT
Program to Demonstrate For Next Loop.

Imports System.Drawing.Imaging
Public Class Form1
Private Sub Button1_Click(sender As Object, e As
EventArgs) Handles Button1.Click
Dim num, sum As Integer
num = 10
For num = 1 To 10
sum = sum + num
MsgBox(sum)
Next
End Sub
End Class
OUTPUT
Program to Demonstrate Do Loop.

Imports System
Module Program
Sub Main(args As String())
Console.WriteLine("Program to display N natural
numbers ")
Dim num As Integer
Dim i As Integer = 1
Console.WriteLine("Enter value of your choice: ")
num = Console.ReadLine()
Do While (i <= num)
Console.WriteLine(i)
i=i+1
Loop
Console.ReadLine()
End Sub
End Module
OUTPUT
Program to Demonstrate Do While Loop.

Imports System
Imports System.Linq.Expressions
Module Program
Sub Main(args As String())
Console.WriteLine("Program to display sum of N
natural numbers")
Dim num As Integer
Dim i As Integer
Dim sum As Integer
i=1
sum = 0
Console.WriteLine("Enter value of your choice ")
num = Console.ReadLine()
Console.WriteLine("Values are: ")
Do
sum = sum + i
i=i+1
Console.WriteLine(i)
Loop While (i <= num)
Console.WriteLine("Sum is : {0}", sum)
Console.ReadLine()
End Sub
End Module

OUTPUT
Program to Create Mathematical Table

Imports System
Module Program
Sub Main(args As String())
Console.WriteLine("Program to display table using
For Next Loop")
Dim num, i As Integer
i=1
Console.WriteLine("Enter the number to print the
table: ")
num = Console.ReadLine()
Console.WriteLine("Table of ")
For i = 1 To 20
Console.WriteLine(num & "*" & i & "=" & i *
num)
Next
Console.ReadKey()
End Sub
End Module
OUTPUT
Program to find even and odd numbers Using
While Loop
Imports System
Imports System.ComponentModel.Design
Module Program
Sub Main(args As String())
Console.WriteLine("Program to find even and odd
numbers")
Dim num, i As Integer
i=1
Console.WriteLine("enter the value for num: ")
num = Console.ReadLine()
While i <= num
If (i Mod 2 = 0) Then
Console.WriteLine("{0} is even number", i)
Else
Console.WriteLine("{0} is odd number", i)
End If
i=i+1
End While
Console.ReadLine()
End Sub
End Module
OUTPUT
Program to find First N Natural Numbers

Public Class Form1


Private Sub Button1_Click(ByVal sender As
System.Object, ByVal e As System.EventArgs) Handles
Button1.Click
Dim num, i As Integer
i=1
For num = 2 To 4
Me.Button1.Text = Me.Button1.Text &
i.ToString & vbCrLf

i=i+1
MsgBox(i)
Next

End Sub
Private Sub Button1_Load(ByVal sender As
System.Object, ByVal e As System.EventArgs) Handles
Me.Load
Button1.Text = ""
End Sub

End Class
OUTPUT
Program to Demonstrate Arrays
Public Class Form1
Private Sub Button1_Click(sender As Object, e As
EventArgs) Handles Button1.Click
Dim markList(10) As Double
Dim marks As Double
Dim i As Integer
marks = 85.5
For i = 0 To 10
markList(i) = marks
marks = marks + 2.5
Next
For i = 0 To 10
MsgBox(markList(i))
Next
End Sub
End Class
OUTPUT
Program to Demonstrate Arrays Numbers

Public Class Form1


Private Sub Button1_Click(sender As Object, e As
EventArgs) Handles Button1.Click
Dim numSq() As Integer = {1, 2, 3, 4, 5 }
For Each number As Integer In numSq
If number >= 5 And number <= 8 Then
Continue For
End If
If number = 10 Then
Exit For
End If
MsgBox(number, ,)
Next
End Sub
End Class
OUTPUT
Program to Demonstrate 2D Arrays

Imports System.Drawing.Drawing2D
Imports System.Security.Policy
Public Class Form1
Private Sub Button1_Click(sender As Object, e As
EventArgs) Handles Button1.Click
Dim Matrix(,) As Integer = {{1, 2}, {3, 4}, {5, 6}}
Dim i, j As Integer
For i = 0 To 2
For j = 0 To 1
MsgBox(Matrix(i, j),)
Next j
Next i
End Sub
End Class
OUTPUT
Program to Demonstrate Arrays Class

Public Class Form1


Private Sub Button1_Click(sender As Object, e As
EventArgs) Handles Button1.Click
Dim code1() As Integer = {1, 2, 3}
Dim code2() As Integer = code1
Dim code3() As Integer = {6, 7, 8}
Dim i As Integer
For i = 0 To 2
MsgBox("Element of First Array:" & code1(i))
MsgBox("Element of Second Array:" & code2(i))
Next i
For i = 0 To 2
MsgBox("Element of Third Array:" & code3(i))
Next i
code2(2) = 4
MsgBox(code2(2))
MsgBox(code1(2))
Array.Copy(code1, code3, code1.Length)
For i = 0 To 2
MsgBox("Element of Third Array:" & code3(i))
Next i
End Sub
End Class

OUTPUT

1
Program to Demonstrate Sub Procedure
Imports System
Module Program
Sub Main()
Console.WriteLine("Creating a Sub Procedure")
DemoProcedure()
End Sub
Sub DemoProcedure()
Console.WriteLine("I am using sub Procedure in
Vb.Net")
Console.WriteLine("Press any key to Exit")
Console.ReadKey()
End Sub
End Module
OUTPUT
Program to find Maximum among two numbers using
functions
Imports System
Imports
System.Security.Cryptography.X509Certificates
Module Program
Sub Main()
Console.WriteLine("Program to find Maximum
among two numbers using functions")
Dim a, b As Integer
Console.WriteLine("Enter the value of a: ")
a = Console.ReadLine()
Console.WriteLine("Enter the value of a: ")
b = Console.ReadLine
Dim max As Integer = FindMax(a, b)
Console.WriteLine("The largest number is {0} ",
max)
Console.WriteLine("Press any key to exit")
End Sub
Function FindMax(ByVal num1 As Integer, ByVal
num2 As Integer) As Integer
Dim Result As Integer
If (num1 > num2) Then
Result = num1
Else
Result = num2
End If
Return Result
End Function
End Module

OUTPUT
Program to find sum of two numbers using function

Module Program
Sub Main()
Console.WriteLine("Program to find sum of two
numbers using function")
Dim a, b As Integer
Console.WriteLine("Enter the value of a: ")
a = Console.ReadLine()
Console.WriteLine("Enter the value of b: ")
b = Console.ReadLine()
Dim sum As Integer = FindSum(a, b)
Console.WriteLine("Sum of two numbers is {0} ",
sum)
Console.WriteLine("Press any key to exit")
Console.ReadKey()
End Sub
Function FindSum(ByVal num1 As Integer, ByVal
num2 As Integer) As Integer
Dim Result As Integer
Result = num1 + num2
FindSum = Result
End Function
End Module
OUTPUT
Program to find factorial of n number using recursion

Imports System
Module Program
Function factorial(ByVal num As Integer)
Dim result As Integer
If num = 1 Then
Return 1
Else
result = factorial(num - 1) * num
Return result
End If
End Function
Sub main()
Console.WriteLine("Program to find factorial of n
number using recursion")
Dim n As Integer
Console.WriteLine("Enter the value of n: ")
n = Console.ReadLine()
Console.WriteLine("Factorial={0}", factorial(n))
Console.ReadKey()
End Sub
End Module
OUTPUT
Program to swap two numbers as passing argument by
Value

Imports System
Module Program
Sub Main(args As String())
Console.WriteLine("Program to swap two numbers
as passing argument by Value")
Dim a, b As Integer
Console.WriteLine("Enter the value of a and b")
a = Console.ReadLine()
b = Console.ReadLine()
Console.WriteLine("Before calling Swap
procedure")
Console.WriteLine("a is {0}", a)
Console.WriteLine("b is {0}", b)
Swap(a, b)
Console.WriteLine("After calling swap procedure")
Console.WriteLine("a is {0}", a)
Console.WriteLine("b is {0}", b)
Console.WriteLine("Press any key exit")
Console.ReadLine()
End Sub
Sub Swap(ByVal a As Byte, ByVal b As Byte)
Dim temp As Byte
temp = a
a=b
b = temp
Console.WriteLine("Inside Swap procedure")
Console.WriteLine("a is {0}", a)
Console.WriteLine("b is {0}", b)
End Sub
End Module

OUTPUT
Program to find factorial of a number using recursion

Imports System
Module Program
Function factorial(ByVal num As Integer)
Dim result As Integer
If num = 1 Then
Return 1
Else
result = factorial(num - 1) * num
Return result
End If
End Function
Sub main()
Console.WriteLine("Program to find factorial of n
number using recursion")
Dim n As Integer
Console.WriteLine("Enter the value of n: ")
n = Console.ReadLine()
Console.WriteLine("Factorial={0}", factorial(n))
Console.ReadKey()
End Sub
End Module
OUTPUT

Program to swap two numbers as passing argument by


Value
Imports System
Module Program
Sub Main(args As String())
Console.WriteLine("Program to swap two numbers
as passing argument by Value")
Dim a, b As Integer
Console.WriteLine("Enter the value of a and b")
a = Console.ReadLine()
b = Console.ReadLine()
Console.WriteLine("Before calling Swap
procedure")
Console.WriteLine("a is {0}", a)
Console.WriteLine("b is {0}", b)
Swap(a, b)
Console.WriteLine("After calling swap procedure")
Console.WriteLine("a is {0}", a)
Console.WriteLine("b is {0}", b)
Console.WriteLine("Press any key exit")
Console.ReadLine()
End Sub
Sub Swap(ByVal a As Byte, ByVal b As Byte)
Dim temp As Byte
temp = a
a=b
b = temp
Console.WriteLine("Inside Swap procedure")
Console.WriteLine("a is {0}", a)
Console.WriteLine("b is {0}", b)
End Sub
End Module

OUTPUT

Program to Swap two numbers as passing arguments by


Reference
Imports System
Module Program
Sub Main()
Console.WriteLine("Program to Swap two numbers
as passing arguments by Reference")
Dim a, b As Integer
Console.WriteLine("Enter th values of a and b ")
a = Console.ReadLine()
b = Console.ReadLine()
Console.WriteLine("Values before swapping")
Console.WriteLine("a is {0}", a)
Console.WriteLine("b is {0}", b)
Swap(a, b)
Console.WriteLine("After swapping ")
Console.WriteLine("a is {0}", b)
Console.WriteLine("b is {0}", b)
Console.WriteLine("Press any key to exit")
Console.ReadLine()
End Sub
Sub Swap(ByRef a As Byte, ByRef b As Byte)
Dim temp As Byte
temp = a
a=b
b = temp
Console.WriteLine("Inside Swap procedure")
Console.WriteLine("a is {0}", a)
Console.WriteLine("b is {0}", b)
End Sub
End Module
OUTPUT

Program to enter students' detail with class and objects


Imports System
Module Program
Class Marks
Private marks As Integer
Sub SetMarks(ByVal m As Integer)
marks = m
End Sub
Sub PrintMarks()
Console.WriteLine(vbTab & "marks : " & marks)
End Sub
End Class
Class Student
Private roll_no As Integer
Private name As String
Private fees As Integer
Private address As String
Sub ReadInfo()
Console.Write("Enter roll number: ")
roll_no = Integer.Parse(Console.ReadLine())
Console.Write("Enter student name: ")
name = Console.ReadLine()
Console.Write("Enter student fees: ")
fees = Integer.Parse(Console.ReadLine())
Console.Write("Enter student address: ")
address = Console.ReadLine()
End Sub
Sub PrintInfo()
Console.WriteLine("Student Information")
Console.WriteLine(vbTab & "Roll Number: " & roll_no)
Console.WriteLine(vbTab & "Roll Name : " & name)
Console.WriteLine(vbTab & "Fees : " & fees)
Console.WriteLine(vbTab & "address : " & address)
End Sub
End Class
Sub Main()
Dim S As New Student
S.ReadInfo()
S.PrintInfo()
End Sub
End Module
OUTPUT

Program to Demonstrate Inheritance

Imports System
Module Program
Public Class User
Public Name As String
Private Location As String
Public Sub New()
Console.WriteLine("Base Class Constructor")
End Sub
Public Sub GetUserInfo(ByVal loc As String)
Location = loc
Console.WriteLine("Name: {0}", Name)
Console.WriteLine("Location: {0}", Location)
End Sub
End Class

Public Class Details


Inherits User
Public Age As Integer
Public Sub New()
Console.WriteLine("Child Class Constructor")
End Sub
Public Sub GetAge()
Console.WriteLine("Age: {0}", Age)
End Sub
End Class
Class Program
Public Shared Sub Main(ByVal args As String())
Dim d As Details = New Details()
d.Name = "Suresh Dasari"
d.Age = 32
d.GetUserInfo("Hyderabad")
d.GetAge()
Console.WriteLine(vbLf & "Press Any Key to Exit..")
Console.ReadLine()
End Sub
End Class
End Module
OUTPUT
Program is to illustrate Encapsulation

Imports System
Module Module1
Class User
Private location As String
Private name As String
Public Property Ulocation() As String Get Return location
End Get Set(ByVal value As String)
location = value

End Set
End Property
Public Property Uname() As String
Get
Return name
End Get
Set(ByVal value As String)
name = value
End Set
End Property
End Class

Sub Main()
Dim u As User = New User()
u.Uname = "Mohit"
u.Ulocation = "Rajouri"
Console.WriteLine("Program is to illustrate
Encapsulation")
Console.WriteLine("Name: " & u.Uname)
Console.WriteLine("Location: " & u.Ulocation)
Console.WriteLine("Press Enter Key to Exit..")
Console.ReadLine()
End Sub
End Module

OUTPUT
Program to Demonstrate simple windows form

Public Class Form1


Private Sub Button1_Click(sender As Object, e As
EventArgs) Handles Button1.Click
Dim name As String
Dim pass As Integer
name = TextBox1.Text
pass = TextBox2.Text
MsgBox("Wellcome to form")
MsgBox("Username is " & name)
MsgBox("Password is " & pass)
End Sub
End Class
OUTPUT
Program to Create Mathematical and Scientific
calculator
Imports System.DirectoryServices.ActiveDirectory
Public Class Form1
Dim a, b, c As Double
Dim op As String
Private Sub TabPage1_Click(sender As Object, e As
EventArgs) Handles TabPage1.Click
End Sub
Private Sub Button3_Click(sender As Object, e As
EventArgs) Handles Button3.Click, Button6.Click,
Button5.Click, Button8.Click, Button12.Click,
Button11.Click, Button10.Click, Button16.Click,
Button15.Click, Button14.Click
Dim b As Button = sender
If Label2.Text = "0" Then
Label2.Text = b.Text
Else
Label2.Text = Label2.Text + b.Text
End If
End Sub
Private Sub Operators(sender As Object, e As
EventArgs) Handles Button7.Click, Button9.Click,
Button13.Click, Button19.Click
Dim ops As Button = sender
a = Label2.Text
Label3.Text = Label2.Text
Label2.Text = ""
op = ops.Text
Label3.Text = Label3.Text + "" + op
End Sub

Private Sub Button1_Click(sender As Object, e As


EventArgs) Handles Button1.Click
If Label2.Text.Contains("-") Then
Label2.Text = Label2.Text.Remove(0, 1)
Else
Label2.Text = "-" + Label2.Text
End If
End Sub

Private Sub Button2_Click(sender As Object, e As


EventArgs) Handles Button2.Click
If InStr(Label2.Text, ".") Then
Label2.Text = Label2.Text + "."
End If
End Sub

Private Sub Button21_Click(sender As Object, e As


EventArgs) Handles Button21.Click
Dim pi As Button = sender
Label2.Text = 3.1415926535897931

End Sub

Private Sub Button18_Click(sender As Object, e As


EventArgs) Handles Button18.Click
b = Label2.Text
c=b^2
Label2.Text = c
End Sub

Private Sub Button20_Click(sender As Object, e As


EventArgs) Handles Button20.Click
b = Label2.Text
c = Math.Sqrt(b)
Label2.Text = c
End Sub
Private Sub Button4_Click(sender As Object, e As
EventArgs) Handles Button4.Click
b = Label2.Text
If op = "+" Then
c=a+b
Label2.Text = c
Label3.Text = ""
ElseIf op = "-" Then
c=a-b
Label2.Text = c
Label3.Text = ""
ElseIf op = "/" Then
c=a/b
Label2.Text = c
Label3.Text = ""
ElseIf op = "X" Then
c=a*b
Label2.Text = c
Label3.Text = ""
End If
End Sub

Private Sub Label1_Click(sender As Object, e As


EventArgs) Handles Label1.Click
Application.Exit()
End Sub

Private Sub Button23_Click(sender As Object, e As


EventArgs) Handles Button23.Click
Label2.Text = "0"
End Sub

Private Sub Button22_Click(sender As Object, e As


EventArgs) Handles Button22.Click
Label2.Text = "0"
Label3.Text = ""

End Sub

Private Sub Button24_Click(sender As Object, e As


EventArgs) Handles Button24.Click
If Label2.Text.Length > 0 Then
Label2.Text =
Label2.Text.Remove(Label2.Text.Length - 1, 1)
End If
End Sub

Private Sub TabPage2_Click(sender As Object, e As


EventArgs) Handles TabPage2.Click
End Sub

Private Sub Button46_Click(sender As Object, e As


EventArgs) Handles Button46.Click, Button33.Click,
Button34.Click, Button35.Click, Button37.Click,
Button38.Click, Button39.Click, Button41.Click,
Button43.Click, Button44.Click
Dim b As Button = sender
If Label5.Text = "0" Then
Label5.Text = b.Text
Else
Label5.Text = Label5.Text + b.Text
End If
End Sub

Private Sub Button48_Click(sender As Object, e As


EventArgs) Handles Button48.Click
If Label5.Text.Contains("-") Then
Label5.Text = Label5.Text.Remove(0.1)
Else
Label5.Text = "-" + Label5.Text
End If
End Sub
Private Sub Button47_Click(sender As Object, e As
EventArgs) Handles Button47.Click
If InStr(Label5.Text, ".") = "0" Then
Label5.Text = Label5.Text + "."
End If
End Sub

Private Sub Button58_Click(sender As Object, e As


EventArgs) Handles Button58.Click
If Label5.Text.Length > 0 Then
Label5.Text =
Label5.Text.Remove(Label5.Text.Length - 1, 1)
End If
End Sub

Private Sub Button42_Click(sender As Object, e As


EventArgs) Handles Button42.Click, Button40.Click,
Button36.Click, Button30.Click, Button57.Click
Dim ops As Button = sender
a = Label5.Text
Label4.Text = Label5.Text
Label5.Text = ""
op = ops.Text
Label4.Text = Label4.Text + "" + op
End Sub

Private Sub Button45_Click(sender As Object, e As


EventArgs) Handles Button45.Click
b = Label5.Text
If op = "+" Then
Label5.Text = c
Label5.Text = ""
ElseIf op = "-" Then
c=a-b
Label5.Text = c
Label4.Text = ""
ElseIf op = "/" Then
c=a/b
Label5.Text = c
Label4.Text = ""
ElseIf op = "X" Then
c=a*b
Label5.Text = c
Label4.Text = ""
ElseIf op = "r" Then
c = Math.Pow(a, 1 / b)
Label5.Text = c
Label4.Text = ""
End If
End Sub

Private Sub Button59_Click(sender As Object, e As


EventArgs) Handles Button59.Click
Label5.Text = "0"
End Sub

Private Sub Button60_Click(sender As Object, e As


EventArgs) Handles Button60.Click
Label5.Text = "0"
Label4.Text = " "
End Sub

Private Sub Button32_Click(sender As Object, e As


EventArgs) Handles Button32.Click
Dim pi As Button = sender
Label5.Text = 3.1415926535897931
End Sub

Private Sub Button31_Click(sender As Object, e As


EventArgs) Handles Button31.Click
Dim ee As Button = sender
Label5.Text = 2.7182818284590451
End Sub

Private Sub Button29_Click(sender As Object, e As


EventArgs) Handles Button29.Click
b = Label5.Text
c = Math.Log10(b)
Label5.Text = c
End Sub

Private Sub Button28_Click(sender As Object, e As


EventArgs) Handles Button28.Click
b = Label5.Text
c = Math.Log(b)
Label5.Text = c
End Sub

Private Sub Button25_Click(sender As Object, e As


EventArgs) Handles Button25.Click
b = Label5.Text
c=b^2
Label5.Text = c
End Sub

Private Sub Button49_Click(sender As Object, e As


EventArgs) Handles Button49.Click
b = Label5.Text
c=b^3
Label5.Text = c
End Sub

Private Sub Button51_Click(sender As Object, e As


EventArgs) Handles Button51.Click
b = Label5.Text
c = 10 ^ b
Label5.Text = c
End Sub

Private Sub Button56_Click(sender As Object, e As


EventArgs) Handles Button56.Click
b = Label5.Text
c = 2.7182818284590451 ^ b
Label5.Text = c
End Sub

Private Sub Button55_Click(sender As Object, e As


EventArgs) Handles Button55.Click
b = Label5.Text
c=2^b
Label5.Text = c
End Sub

Private Sub Button54_Click(sender As Object, e As


EventArgs) Handles Button54.Click
b = Label5.Text
c = Math.Sqrt(b)
Label5.Text = c
End Sub

Private Sub Button52_Click(sender As Object, e As


EventArgs) Handles Button52.Click
b = Label5.Text
c=1/b
Label5.Text = c
End Sub

Private Sub Button53_Click(sender As Object, e As


EventArgs) Handles Button53.Click
b = Label5.Text
c = Math.Cbrt(b)
Label5.Text = c
End Sub

Private Sub Button61_Click(sender As Object, e As


EventArgs) Handles Button61.Click
If CheckBoxDEG.Checked = True AndAlso
CheckBoxRAD.Checked = False AndAlso
CheckBoxgRAD.Checked = False Then
b = Label5.Text
c = Math.Sin(b * (Math.PI / 180))
Label5.Text = c
ElseIf CheckBoxDEG.Checked = False AndAlso
CheckBoxRAD.Checked = True AndAlso
CheckBoxgRAD.Checked = False Then
b = Label5.Text
c = Math.Sin(b)
Label5.Text = c
ElseIf CheckBoxDEG.Checked = False AndAlso
CheckBoxRAD.Checked = False AndAlso
CheckBoxgRAD.Checked = True Then
b = Label5.Text
c = Math.Sin((b * (Math.PI / 180)) * (9 / 10))
Label5.Text = c
End If
End Sub

Private Sub Button62_Click(sender As Object, e As


EventArgs) Handles Button62.Click
If CheckBoxDEG.Checked = True AndAlso
CheckBoxRAD.Checked = False AndAlso
CheckBoxgRAD.Checked = False Then
b = Label5.Text
c = Math.Cos(b * (Math.PI / 180))
Label5.Text = c
ElseIf CheckBoxDEG.Checked = False AndAlso
CheckBoxRAD.Checked = True AndAlso
CheckBoxgRAD.Checked = False Then
b = Label5.Text
c = Math.Cos(b)
Label5.Text = c
ElseIf CheckBoxDEG.Checked = False AndAlso
CheckBoxRAD.Checked = False AndAlso
CheckBoxgRAD.Checked = True Then
b = Label5.Text
c = Math.Cos((b * (Math.PI / 180)) * (9 / 10))
Label5.Text = c
End If
End Sub

Private Sub Button63_Click(sender As Object, e As


EventArgs) Handles Button63.Click
If CheckBoxDEG.Checked = True AndAlso
CheckBoxRAD.Checked = False AndAlso
CheckBoxgRAD.Checked = False Then
b = Label5.Text
c = Math.Tan(b * (Math.PI / 180))
Label5.Text = c
ElseIf CheckBoxDEG.Checked = False AndAlso
CheckBoxRAD.Checked = True AndAlso
CheckBoxgRAD.Checked = False Then
b = Label5.Text
c = Math.Tan(b)
Label5.Text = c
ElseIf CheckBoxDEG.Checked = False AndAlso
CheckBoxRAD.Checked = False AndAlso
CheckBoxgRAD.Checked = True Then
b = Label5.Text
c = Math.Tan((b * (Math.PI / 180)) * (9 / 10))
Label5.Text = c
End If
End Sub

Private Sub Button66_Click(sender As Object, e As


EventArgs) Handles Button66.Click
If CheckBoxDEG.Checked = True AndAlso
CheckBoxRAD.Checked = False AndAlso
CheckBoxgRAD.Checked = False Then
b = Label5.Text
c = 1 / (Math.Sin(b * (Math.PI / 180)))
Label5.Text = c
ElseIf CheckBoxDEG.Checked = False AndAlso
CheckBoxRAD.Checked = True AndAlso
CheckBoxgRAD.Checked = False Then
b = Label5.Text
c = 1 / (Math.Sin(b))
Label5.Text = c
ElseIf CheckBoxDEG.Checked = False AndAlso
CheckBoxRAD.Checked = False AndAlso
CheckBoxgRAD.Checked = True Then
b = Label5.Text
c = 1 / Math.Sin((b * (Math.PI / 180)) * (9 / 10))
Label5.Text = c
End If
End Sub

Private Sub Button65_Click(sender As Object, e As


EventArgs) Handles Button65.Click
If CheckBoxDEG.Checked = True AndAlso
CheckBoxRAD.Checked = False AndAlso
CheckBoxgRAD.Checked = False Then
b = Label5.Text
c = 1 / (Math.Cos(b * (Math.PI / 180)))
Label5.Text = c
ElseIf CheckBoxDEG.Checked = False AndAlso
CheckBoxRAD.Checked = True AndAlso
CheckBoxgRAD.Checked = False Then
b = Label5.Text
c = Math.Sin(b)
Label5.Text = c
ElseIf CheckBoxDEG.Checked = False AndAlso
CheckBoxRAD.Checked = True AndAlso
CheckBoxgRAD.Checked = False Then
b = Label5.Text
c = 1 / (Math.Cos(b))
Label5.Text = c
ElseIf CheckBoxDEG.Checked = False AndAlso
CheckBoxRAD.Checked = False AndAlso
CheckBoxgRAD.Checked = True Then
b = Label5.Text
c = 1 / Math.Cos((b * (Math.PI / 180)) * (9 / 10))
Label5.Text = c
End If
End Sub

Private Sub Button64_Click(sender As Object, e As


EventArgs) Handles Button64.Click
If CheckBoxDEG.Checked = True AndAlso
CheckBoxRAD.Checked = False AndAlso
CheckBoxgRAD.Checked = False Then
b = Label5.Text
c = 1 / (Math.Tan(b * (Math.PI / 180)))
Label5.Text = c
ElseIf CheckBoxDEG.Checked = False AndAlso
CheckBoxRAD.Checked = True AndAlso
CheckBoxgRAD.Checked = False Then
b = Label5.Text
c = 1 / (Math.Tan(b))
Label5.Text = c
ElseIf CheckBoxDEG.Checked = False AndAlso
CheckBoxRAD.Checked = False AndAlso
CheckBoxgRAD.Checked = True Then
b = Label5.Text
c = 1 / Math.Tan((b * (Math.PI / 180)) * (9 / 10))
Label5.Text = c
End If
End Sub
Private Sub Button69_Click(sender As Object, e As
EventArgs) Handles Button69.Click
If CheckBoxDEG.Checked = True AndAlso
CheckBoxRAD.Checked = False AndAlso
CheckBoxgRAD.Checked = False Then
b = Label5.Text
c = Math.Asin(b) * (180 / Math.PI)
Label5.Text = c
ElseIf CheckBoxDEG.Checked = False AndAlso
CheckBoxRAD.Checked = True AndAlso
CheckBoxgRAD.Checked = False Then
b = Label5.Text
c = Math.Asin(b)
Label5.Text = c
ElseIf CheckBoxDEG.Checked = False AndAlso
CheckBoxRAD.Checked = False AndAlso
CheckBoxgRAD.Checked = True Then
b = Label5.Text
c = Math.Asin((b * (Math.PI / 180)) * (9 / 10))
Label5.Text = c
End If
End Sub

Private Sub Button68_Click(sender As Object, e As


EventArgs) Handles Button68.Click
If CheckBoxDEG.Checked = True AndAlso
CheckBoxRAD.Checked = False AndAlso
CheckBoxgRAD.Checked = False Then
b = Label5.Text
c = Math.Acos(b) * (180 / Math.PI)
Label5.Text = c
ElseIf CheckBoxDEG.Checked = False AndAlso
CheckBoxRAD.Checked = True AndAlso
CheckBoxgRAD.Checked = False Then
b = Label5.Text
c = Math.Acos(b)
Label5.Text = c
ElseIf CheckBoxDEG.Checked = False AndAlso
CheckBoxRAD.Checked = False AndAlso
CheckBoxgRAD.Checked = True Then
b = Label5.Text
c = Math.Acos((b * (Math.PI / 180)) * (9 / 10))
Label5.Text = c
End If
End Sub

Private Sub Button67_Click(sender As Object, e As


EventArgs) Handles Button67.Click
If CheckBoxDEG.Checked = True AndAlso
CheckBoxRAD.Checked = False AndAlso
CheckBoxgRAD.Checked = False Then
b = Label5.Text
c = Math.Atan(b) * (180 / Math.PI)
Label5.Text = c
ElseIf CheckBoxDEG.Checked = False AndAlso
CheckBoxRAD.Checked = True AndAlso
CheckBoxgRAD.Checked = False Then
b = Label5.Text
c = Math.Atan(b)
Label5.Text = c
ElseIf CheckBoxDEG.Checked = False AndAlso
CheckBoxRAD.Checked = False AndAlso
CheckBoxgRAD.Checked = True Then
b = Label5.Text
c = Math.Atan((b * (Math.PI / 180)) * (9 / 10))
Label5.Text = c
End If
End Sub

Private Sub Button27_Click(sender As Object, e As


EventArgs) Handles Button27.Click
Dim n As Int64
Dim i As Int64
Dim f As Int64
n = Label5.Text
f=1
If n >= 0 Then
For i = 1 To n
f=i*f
Next
Label5.Text = f
End If
End Sub
End Class

OUTPUT
Program to create registration form with ADO.Net

Imports System.Data.SqlClient

Public Class register


Private Sub Button1_Click(sender As Object, e As
EventArgs) Handles Button1.Click
Dim con As New SqlConnection
Dim cmd As New SqlCommand

con.ConnectionString = " Data


Source=(LocalDB)\MSSQLLocalDB;AttachDbFilename=C
:\Users\mohit\OneDrive\Desktop\form\RegistrationFo
rm\RegistrationForm\registration.mdf;Integrated
Security=True;Connect Timeout=30"
con.Open()
If fname.Text <> "" And lname.Text <> "" And
gender.Text <> "" And phone.Text <> "" And email.Text
<> "" And password.Text <> "" Then
cmd = New SqlCommand("INSERT INTO users
values('" & fname.Text & "','" & lname.Text & "','" &
gender.Text & "','" & phone.Text & "','" & email.Text &
"','" & password.Text & "')", con)
cmd.ExecuteNonQuery()
MsgBox("Sucessfully Registered",
MsgBoxStyle.Information, "Sucess")
Me.Hide()
fname.Clear()
lname.Clear()
phone.Clear()
email.Clear()
password.Clear()
Else
MessageBox.Show("Please Enter all the fields")

End If
con.Close()
End Sub
Private Sub cancel_register_Click(sender As Object, e
As EventArgs) Handles cancel_register.Click
Me.Hide()
Form1.Show()
End Sub
End Class
OUTPUT
Program to create login form with ADO.Net

Imports System.Data.SqlClient
Public Class Login
Private Sub Button2_Click(sender As Object, e As
EventArgs) Handles Button2.Click
Dim con As New SqlConnection
Dim cmd As New SqlCommand
con.ConnectionString = "Data
Source=(LocalDB)\MSSQLLocalDB;AttachDbFilename=C
:\Users\mohit\OneDrive\Desktop\form\RegistrationFo
rm\RegistrationForm\registration.mdf;Integrated
Security=True"
con.Open()
Dim stmt As String = "Select * From users WHERE
email='" & email.Text & "' AND password = '" &
password.Text & "'"
cmd = New SqlCommand(stmt, con)
Dim reader As SqlDataReader =
cmd.ExecuteReader
If reader.Read Then
MessageBox.Show("you have logged in
Successfully")
Me.Hide()
Else
MessageBox.Show("Invalid username or
password")
email.Clear()
password.Clear()
End If
con.Close()
End Sub

Private Sub Button1_Click(sender As Object, e As


EventArgs) Handles Button1.Click
Me.Hide()
Form1.Show()
End Sub
End Class
OUTPUT
Program to create a web form with asp.net

Public Class _Default


Inherits System.Web.UI.Page
Protected Sub Button1_Click(sender As Object, e As
EventArgs) Handles Button1.Click
Dim num1 As Integer =
Convert.ToInt32(TextBox1.Text)
Dim num2 As Integer =
Convert.ToInt32(TextBox2.Text)
Dim sum As Integer = num1 + num2
Button1.Text = "Sum: " & sum
End Sub
End Class
OUTPUT

You might also like