You are on page 1of 25

EN NO : 202002100410008

PRACTICAL : 1

Aim : Condition Statements in Vb.Net.

1) If Then Statement

CODE :

Module VBModule

Sub Main()
Dim a As Integer = 10
Dim b As Integer = 10

if(a = b)Then
Console.WriteLine("A is Equals to B")
End if

End Sub

End Module

OUTPUT :
EN NO : 202002100410008

2) If Then Else Statement

CODE :

Module VBModule

Sub Main()
Dim a As Integer = 10
Dim b As Integer = 20

if(a = b)Then
Console.WriteLine("A is Equals to B")
Else
Console.WriteLine("A is Not Equals to B")
End if

End Sub

End Module

OUTPUT :
EN NO : 202002100410008

3) If Then Elseif Statement

CODE :

Module VBModule

Sub Main()
Dim a As Integer = 10
Dim b As Integer = 20
Dim c As Integer = 10

if(a = b)Then
Console.WriteLine("A is Equals to B")
Elseif(a = c)Then
Console.WriteLine("A is Equals to C")
End if

End Sub

End Module

OUTPUT :
EN NO : 202002100410008

4) Select Case Statement

CODE :

Module VBModule

Sub Main()
Dim A As Integer
A = Console.ReadLine()

Select Case A
Case 1
Console.WriteLine("Case 1 is Executed")
Case 2
Console.WriteLine("Case 2 is Executed")
End Select

End Sub

End Module

OUTPUT :
EN NO : 202002100410008

PRACTICAL : 2

Aim : Addition of Two Numbers Enter By User in Vb.Net.

CODE :

Module VBModule

Sub Main()
Dim A As Integer
Dim B As Integer

Console.WriteLine("202002100410008")
Console.WriteLine("Enter First Number :")
A = Console.ReadLine()
Console.WriteLine("Enter Second Number : ")
B = Console.ReadLine()

Console.WriteLine("Addition of Two Numbers : "&A+B)

End Sub

End Module

OUTPUT :
EN NO : 202002100410008

PRACTICAL : 3

Aim : Calculator in Vb.Net using Select Case.

CODE :

Module VBModule

public Sec As Integer


public A As Integer
public B As Integer
public Sum As Integer
public Subb As Integer
public Multi As Integer
Public dx As Double

Sub Main()

Console.WriteLine("202002100410008")
Console.WriteLine("Select operation you want to perform")
Console.WriteLine("1: Addition")
Console.WriteLine("2: Subtraction")
Console.WriteLine("3: Multiplication")
Console.WriteLine("4: Division")

Console.Write("Enter Value of A : ")


A = Integer.Parse(Console.ReadLine())

Console.Write("Enter Value of B : ")


B = Integer.Parse(Console.ReadLine())

Console.Write("Enter choice: ")


Sec = Console.ReadLine()

'if(A >= 0 And B >= 0)


Select sec
Case 1
EN NO : 202002100410008

Sum = A + B
Console.WriteLine("Addition of A and B is : " & Sum)
Case 2
Subb = A - B
Console.WriteLine("Substraction of A and B is : " & Subb)
Case 3
Multi = A * B
Console.WriteLine("Multiplication of A and B is : " & Multi)
Case 4
dx = A / B
Console.WriteLine("Division of A and B is : " & dx)
Case Else
Console.WriteLine("Invalid choice")
End Select

'End if

Console.ReadLine()
End Sub

End Module

OUTPUT :
EN NO : 202002100410008

PRACTICAL : 4

Aim : Rating Grade Entered By User in Vb.Net

CODE :

Module VBModule

Sub Main()
Dim A As String

Console.WriteLine("202002100410008")
Console.WriteLine("Enter Your Grade")
A = Console.ReadLine()

if(A ="A+" or A = "a+" or A = "a") Then


Console.WriteLine("Excellent")
Else if(A = "B" or A = "b")
Console.WriteLine("Good")
Else if(A = "C" or A = "c")
Console.WriteLine("Poor")
Else
Console.WriteLine("Fail")

End if
Console.ReadKey()
End Sub

End Module

OUTPUT :
EN NO : 202002100410008
EN NO : 202002100410008

PRACTICAL : 5

Aim : Inheritance in Vb.Net.

CODE :

public class First


Sub FirstSub()
Console.WriteLine("202002100410008")
Console.WriteLine("First Class")
Dim A As Integer = 5
Dim B As Integer = 10
Console.WriteLine("Addtion of Two Numbers : "&A+B)
End Sub
End class

public class Second: inherits First


Sub SecondSub()
Console.WriteLine("Second Class")
Dim A As Integer = 5
Dim B As Integer = 10
Console.WriteLine("Multiplication of Two Numbers : "&A*B)
End Sub
End class

public class Main

Shared Sub main()


dim a As Second = new Second()
a.FirstSub()
a.SecondSub()

End Sub
End class
EN NO : 202002100410008

OUTPUT :
EN NO : 202002100410008

PRACTICAL : 6

Aim : Registration Form in Vb.Net Using Visual Studio.

CODE :

Private Sub Button1_Click(sender As Object, e As EventArgs) Handles Button1.Click


MsgBox("Full Name : " & TextBox1.Text & " " & TextBox2.Text
& vbNewLine & "Address : " & TextBox3.Text
& vbNewLine & "City And State : " & TextBox4.Text & " "
& TextBox5.Text & vbNewLine & "Zip code : " & TextBox6.Text
& vbNewLine & "Phone Number : " & TextBox7.Text
& vbNewLine & "Email : " & TextBox8.Text)
End Sub

OUTPUT :
EN NO : 202002100410008
EN NO : 202002100410008

PRACTICAL : 7

Aim : Calculator in Vb.Net Using Visual Studio.

CODE :

Private Sub Button17_Click(sender As Object, e As EventArgs) Handles Button17.Click


A = TextBox1.Text
OP = Button17.Text
TextBox1.Text = A * A
sq = True
End Sub

Private Sub Button1_Click_1(sender As Object, e As EventArgs) Handles


Button1.Click

B = TextBox1.Text
TextBox1.Text = ""

Select Case OP
Case "+"
TextBox1.Text = A + B
Case "-"
TextBox1.Text = A - B
Case "x"
TextBox1.Text = A * B
Case "÷"
TextBox1.Text = A / B
End Select

End Sub
EN NO : 202002100410008

OUTPUT :
EN NO : 202002100410008

PRACTICAL : 8

Aim : Currency Calculator in Vb.Net Using Visual Studio.

CODE :

Public Class Form1

Dim var1 As Double


Dim var2 As Double
Dim res As Double

Private Sub Button2_Click(sender As Object, e As EventArgs) Handles Button2.Click


TextBox1.Text = ""
TextBox3.Text = ""
TextBox1.Focus()
End Sub

Private Sub Button1_Click(sender As Object, e As EventArgs) Handles Button1.Click

If (ComboBox1.SelectedItem = "INR") Then


var1 = 1
ElseIf (ComboBox1.SelectedItem = "USD") Then
var1 = 79.86
ElseIf (ComboBox1.SelectedItem = "EUR") Then
var1 = 81.34
ElseIf (ComboBox1.SelectedItem = "CAD") Then
var1 = 61.82
ElseIf (ComboBox1.SelectedItem = "AED") Then
var1 = 21.74
End If

If (ComboBox2.SelectedItem = "INR") Then


var2 = 1
ElseIf (ComboBox2.SelectedItem = "USD") Then
var2 = 79.86
ElseIf (ComboBox2.SelectedItem = "EUR") Then
var2 = 81.34
ElseIf (ComboBox2.SelectedItem = "CAD") Then
EN NO : 202002100410008

var2 = 61.82
ElseIf (ComboBox2.SelectedItem = "AED") Then
var2 = 21.74
End If

res = TextBox1.Text
Dim var As Double

var = res * var1 / var2

TextBox3.Text = var

End Sub

Private Sub Button3_Click(sender As Object, e As EventArgs) Handles Button3.Click


End
End Sub

End Class

OUTPUT :
EN NO : 202002100410008
EN NO : 202002100410008
EN NO : 202002100410008

PRACTICAL : 9

Aim : Moving a Picture Box in Vb.Net Using Visual Studio.

CODE :

Public Class Form1


Private Sub Button1_Click(sender As Object, e As EventArgs) Handles Button1.Click

If (ComboBox1.SelectedItem = "1") Then


PictureBox2.Image = Image.FromFile("C:\Users\Public\Pictures\Sample
Pictures\Desert.jpg")
ElseIf (ComboBox1.SelectedItem = "2") Then
PictureBox2.Image = Image.FromFile("C:\Users\Public\Pictures\Sample
Pictures\Lighthouse.jpg")
ElseIf (ComboBox1.SelectedItem = "3") Then
PictureBox2.Image = Image.FromFile("C:\Users\Public\Pictures\Sample
Pictures\Tulips.jpg")
End If

End Sub

Private Sub PictureBox2_Click(sender As Object, e As EventArgs) Handles


PictureBox2.Click

End Sub

Private Sub Button2_Click(sender As Object, e As EventArgs) Handles Button2.Click


Timer1.Enabled = True
End Sub

Private Sub Button3_Click(sender As Object, e As EventArgs) Handles Button3.Click


End
End Sub

Private Sub Timer1_Tick_1(sender As Object, e As EventArgs) Handles Timer1.Tick


PictureBox2.Location = New Point(PictureBox2.Location.X + 1,
PictureBox2.Location.Y)
EN NO : 202002100410008

End Sub

End Class

OUTPUT :
EN NO : 202002100410008
EN NO : 202002100410008

PRACTICAL : 10
Aim : Paint Application in Vb.Net Using Visual Studio.

CODE :

Public Class Form1

Dim mouseDown As Boolean


Dim EraseOn As Boolean
Dim mybrush

Private Sub PictureBox1_Click(sender As Object, e As EventArgs) Handles


PictureBox1.Click

End Sub

Private Sub PictureBox1_MouseMove(sender As Object, e As


MouseEventArgs) Handles PictureBox1.MouseMove
If (mouseDown) Then
PictureBox1.CreateGraphics.FillEllipse(mybrush, e.X, e.Y, 10, 10)
ElseIf (EraseOn) Then
PictureBox1.CreateGraphics.FillEllipse(mybrush, e.X, e.Y, 50, 50)
End If
End Sub

Private Sub PictureBox1_MouseDown(sender As Object, e As


MouseEventArgs) Handles PictureBox1.MouseDown
mouseDown = True
End Sub

Private Sub PictureBox1_MouseUp(sender As Object, e As MouseEventArgs)


Handles PictureBox1.MouseUp
mouseDown = False
End Sub
Private Sub Button1_Click(sender As Object, e As EventArgs) Handles
Button1.Click
EN NO : 202002100410008

mybrush = Brushes.Black
End Sub
Private Sub Button2_Click(sender As Object, e As EventArgs) Handles
Button2.Click
mybrush = Brushes.Red
End Sub
Private Sub Button4_Click(sender As Object, e As EventArgs) Handles
Button4.Click
mybrush = Brushes.Gray
End Sub
Private Sub Button3_Click(sender As Object, e As EventArgs) Handles
Button3.Click
mybrush = Brushes.Blue
End Sub
Private Sub Button5_Click(sender As Object, e As EventArgs) Handles
Button5.Click
mybrush = Brushes.Green
End Sub
End Class

OUTPUT :
EN NO : 202002100410008

You might also like