You are on page 1of 97

Practical No-1

Aim: Install Set Up and Use VB.Net IDE (Integrated Development


Environment)
STEPS:

Step 1. For downloading the Visual Studio IDE, go through the link given below:

https://www.visualstudio.com/downloads

Select one to download IDE

o Visual Studio 2019 Community Edition


o Visual Studio 2019 Professional Edition (90 Day Free Trial)
o And Visual Studio 2019 Enterprise Edition (90 Day Free Trial)

Step 2. As clicked on download link, it starts downloading an .exe file, as shown in the image
below.
Step 3. Click on the .exe file and then, it shows a pop-up window.

Step 4. Click on the Run button, and then it shows the below image.

Step 5. Click on the Continue Button


Step 6. After clicking on Continue, Visual Studio will start downloading its initial files as shown
in the image below.

Step 7. It shows the screen below, in which you have to click on the install button as shown.
Step 8. After clicking on install button, your Visual Studio IDE will start downloading and then
it displays the screen, as we have shown below.
Step 9. From the above image, select .NET desktop development and click on install open
which may take some time to download the Visual Studio in your system, as shown in below
image.

Step 10. After successfully downloading and installing the Visual Studio' supportive file, it
shows the below screen in your system.

Step 11. Click on Launch button, and then it shows the below image in your screen that
represents Visual Studio has been successfully launched in your machine.
And then it shows a below screen to select the Visual Studio theme. By default, it takes Blue
theme, and if you want to change, you can easily change the Visual Studio theme by clicking on
other themes.

Step 12. After selecting the Theme, click on Start Visual Studio and then it shows a below
image in your system screen for creating a new project.
Step 13. After click on Create a new project, it shows the below screen to choose what type of
application you are going to build in Visual studio. In this you can select the Console based
application or Window Form Based application, as shown in below image. Here we chose the
Console based application, and then click on the Next button.

Step 14. When you click the Next button, it shows the below image to define the project name,
and also reminds if you want to place the solution and project in the same directory.
Step 15. And finally, your new project will be successfully created.
Practical No-2

Aim: Design VB.NET application using Existing Namespaces and User Defined Namespaces.

Program:
Imports System
Namespace outer
Public Class nameout
Public Shared Function disp()
Console.WriteLine("Hii this is outer name space")
End Function

End Class
Namespace inner
Public Class namein
Public Shared Function disp()
Console.WriteLine("Hii this is inner name space")
End Function
End Class
End Namespace
End Namespace
Module namespaceprg
Sub Main()
Console.Clear()
outer.nameout.disp()
outer.inner.namein.disp()
Console.ReadLine()
End Sub

End Module
Output:
EXERCISE:

1. Write a program to implement the namespaces student in your vb.net


application.

Program:
Namespace student
Public Class student_info
Public Shared Function disp()
Console.WriteLine("Name:Nikita")
Console.WriteLine("Branch:Information Technology")
Console.WriteLine("class:SYIT")
End Function
End Class
End Namespace

Module Module1
Sub Main()
Console.Clear()
student.student_info.disp()
Console.ReadLine()
End Sub

End Module

Output:
Practical No-3

Aim: Implement a Message Box program & Arithmetic Expression

Program:
Module Module1
Sub Main()

MsgBox("hello World")

End Sub
End Module

Output:
Exercise:
1. Implement the program to generate result of any arithmetic operation using
MsgBox().

Program:
Module ARITHMETIC_EXP_Msgbox_exercise1
Sub main()
Dim a As Integer = 100
Dim b As Integer = 50
MsgBox("ADDITION=" & Val(a) + Val(b))
MsgBox("SUBSTRACTION=" & Val(a) - Val(b))
MsgBox("MULTIPLICATION=" & Val(a) * Val(b))
MsgBox("DIVISION=" & Val(a) / Val(b))
MsgBox("REMAINDER=" & Val(a) Mod Val(b))
End Sub
End Module
Output:
2. Write a program using InputBox(), MsgBox() & perform various arithmetic
expressions.

Program:
Module inputbox_msgbox_exercise2
Sub main()
Dim a As Integer
Dim b As Integer
a = InputBox("enter value of a:")
b = InputBox("enter value of b:")
MsgBox("ADDITION=" & Val(a) + Val(b))
MsgBox("SUBSTRACTION=" & Val(a) - Val(b))
MsgBox("MULTIPLICATION=" & Val(a) * Val(b))
MsgBox("DIVISION=" & Val(a) / Val(b))
MsgBox("REMAINDER=" & Val(a) Mod Val(b))
End Sub
End Module

Output:
Practical No-4

Aim: Implement a program for If-else control structures in VB.NET.

Program:
Module Module1

Sub Main()
Dim a As Integer
Dim b As Integer
Console.WriteLine("enter value of a:")
a = Integer.Parse(Console.ReadLine())
Console.WriteLine("enter value of b:")
b = Integer.Parse(Console.ReadLine())
If a <= b Then
Console.WriteLine("value of a is less than b")
Else
Console.WriteLine("value of b is greater than a")
End If
Console.ReadLine()
End Sub

End Module

Output:
Practical Related Questions:

1. Implement the program for finding greatest of three numbers.

Program:
Module greatestnobetween3
Sub main()
Dim a As Integer
Dim b As Integer
Dim c As Integer
a = 100
b = 200
c = 150
If a > b Then
If a > c Then
Console.WriteLine("greatestest no is a")
Else
Console.WriteLine("greatestest no is c")
End If
Else
If b > c Then
Console.WriteLine("greatestest no is b")
Else
Console.WriteLine("greatestest no is c")
End If
End If
Console.ReadLine()
End Sub
End Module

Output:
2. Implement the program using if-else statement to find the number is even or
odd.

Program:
Module Module1

Sub Main()
Dim a As Integer
Console.WriteLine("enter any number:")
a = Integer.Parse(Console.ReadLine())
If a Mod 2 = 0 Then
Console.WriteLine("EVEN no!!")
Else
Console.WriteLine("ODD no!!")
End If
Console.ReadLine()
End Sub

End Module

Output:
Exercise:

1. Write a program using if-else statement for the following output.

Program:
Module Module1

Sub Main()
Dim per As Integer
Console.WriteLine("enter percentage")
per = Integer.Parse(Console.ReadLine())
If per >= 75 Then
Console.WriteLine("DISTINCTION class!!")
ElseIf per >= 60 Then
Console.WriteLine("FIRST class!!")
ElseIf per >= 40 Then
Console.WriteLine("PASS class!!")
Else
Console.WriteLine("FAIL!!")
End If
Console.ReadLine()
End Sub

End Module

Output:
2. Write the output of the following code.

Program:
Module Module1
Sub Main()
Dim i As Integer
i=4
Dim a As Double
a = -1.0
If (i > 0) Then
If (a > 0) Then
Console.WriteLine("here i am!!")
Else
Console.WriteLine("no here i am??")
Console.WriteLine("actually here i am??")
Console.ReadLine()
End If
End If
End Sub
End Module

Output:
Practical No-5

Aim: implement a program for select case control structures in vb.net.


Program:
Module Module1

Sub Main()
Dim grade As Char
Console.WriteLine("enter the grade:")
grade = Console.ReadLine()
Select Case grade
Case "A"
Console.WriteLine("EXCELLENT!!")
Case "B"
Console.WriteLine("GOOD!!")
Case "C"
Console.WriteLine("PASS!!")
Case "D"
Console.WriteLine("TRY AGAIN!!")
Case Else
Console.WriteLine("INVALID GRADE")
End Select
Console.WriteLine("YOUR GRADE IS {0}", grade)
Console.ReadLine()
End Sub

End Module

Output:
EXERCISE:

1. Implement a program using select case statement to count the number of


vowels in A to Z alphabets.

Program:
Module pract5_exercise1
Sub main()
Dim str As String = "ABCDEFGHIJKLMNOPQRSTUVWXYZ"
Dim ch as char
Dim count As Integer = 0
For Each ch In str
Select Case ch
Case "A", "E", "I", "O", "U"
count = count + 1
End Select
Next
Console.WriteLine("number of vowels in A to Z={0}", count)
Console.ReadLine()
End Sub
End Module
Output:

2. Develop a program for performing arithmetic operations.

Program:
Module Module1

Sub Main()
Dim a As Integer
Dim b As Integer
Dim choice As Char
Console.WriteLine("enter value of a")
a = Integer.Parse(Console.ReadLine())
Console.WriteLine("enter value of b")
b = Integer.Parse(Console.ReadLine())
Console.WriteLine("A for addition")
Console.WriteLine("B for substraction")
Console.WriteLine("c for multiplication")
Console.WriteLine("D for division")
Console.WriteLine("ENTER YOUR CHOICE")
choice = Console.ReadLine()
Select Case choice
Case "A"
Console.WriteLine("addition of two no is={0}", a + b)
Case "B"
Console.WriteLine("addition of two no is={0}", a - b)
Case "C"
Console.WriteLine("addition of two no is={0}", a * b)
Case "D"
Console.WriteLine("addition of two no is={0}", a / b)
Case Else
Console.WriteLine("INVALID CHOICE")
End Select
Console.ReadLine()
End Sub

End Module

OUTPUT:
Practical No-6

Aim: Implement a program for while, do while loops in VB.NET

While loop program:


Module Module1

Sub Main()
Dim a As Integer = 1
While a <= 20
Console.WriteLine("value of a={0}", a)
a=a+1
End While
Console.ReadLine()
End Sub

End Module

Output:
Do-while loop program:
Module Module1

Sub Main()
Dim a As Integer = 1
Do
Console.WriteLine("value of a={0}", a)
a=a+1

Loop While (a <= 10)


Console.ReadLine()
End Sub

End Module

Output:
EXERCISE:

Write a program using while statement to print the prime numbers between 1-100

Program:
Module exercise_1

Sub Main()

Dim num, i As Integer


Dim b As Boolean
num = 2
Console.WriteLine(" Prime Number From 1 to 100 = ")

b = True

While num <= 100


b = True
i=2

While i < num


If num Mod i = 0 Then
b = False
GoTo break

End If
i += 1
End While
break:
If b Then
Console.WriteLine(num)
End If
num += 1
End While

Console.ReadLine()

End Sub

End Module
Output:

1. Write a program using while statement to print even-odd numbers between


1-50

Program:
Module Module1

Sub Main()
Dim i As Integer
Console.WriteLine("EVEN ODD Numbers between 1 to 50")
Console.WriteLine("No EVEN ODD")
Console.WriteLine("=========================")
For i = 1 To 50
If i Mod 2 = 0 Then
Console.WriteLine(i & " YES NO")
End If
Console.WriteLine(i & " NO YES")
Next
Console.ReadLine()
End Sub

End Module

Output:
Practical No-7

Aim: implement a program to demonstrate the use of for, for-each loops in


vb.net

For loop program:


Module Module1

Sub Main()
Dim i As Integer
For i = 1 To 50
Console.WriteLine(i)
i=i+1
Next
Console.ReadLine()
End Sub
End Module

Output:
For each loop program:

Module Module1

Sub Main()
Dim i As Double
Dim a() As Integer = {10, 20, 30, 40, 50}
For Each i In a
Console.WriteLine(i)
Next
Console.ReadLine()
End Sub

End Module

Output:

Practical Related Questions:

1. Write the output of the following code?

Module PractRelated_1

Sub Main()
For i = 0 To -10 Step -1
Console.WriteLine(i)
Next
Console.ReadKey()
End Sub

End Module
Output:

2. Write a program to generate the following output:

Program:
Module PractRelated_2
Sub main()

Dim i As Double
For i = 3.5 To 8.5

Console.WriteLine(i)
i = i - 0.5

Next
Console.ReadKey()
End Sub
End Module
Exercise:
1. Write the situation where for each loop statements can be implemented.

Program:
Module exercise_1
Sub main()
Dim name = New String() {"Nikita", "Tejal", "Sneha", "Jaya", "Samruddhi"}

For Each letter In name


Console.WriteLine(letter)
Next
Console.ReadLine()
End Sub
End Module

Output:
2. Write a program using for next loop statement to find the Armstrong
numbers between 1 to 500 (153 is Armstrong number 1^3+5^3=3^3=153)

Program:
Module Exercise_2
Sub main()
Dim num, temp, r, s, t As Integer
Console.WriteLine(" Armstrong Number Between 1 to 500: ")
For num = 1 To 500
temp = num
s=0

For t = 0 To num
r = temp Mod 10
s = (r * r * r) + s
temp = temp \ 10
Next

If num = s Then
Console.WriteLine(num)
End If
Next
Console.ReadKey()
End Sub

End Module

Output:
Practical No-8

Aim: Design windows application using Text Box, Label & Button
Practical Related Questions:

1. Write a code to generate the button at runtime in vb.net.

Design screen:

Program:
Public Class practRelated_2
Private Sub Button1_Click(sender As Object, e As EventArgs) Handles Button1.Click
Dim btn As New Button
btn.Name = "btn"
btn.Location = New Point(50, 40)
btn.Size = New Size(150, 30)
btn.Text = "Me here"
Me.Controls.Add(btn)
AddHandler btn.Click, AddressOf btn_click
End Sub
Private Sub btn_click()
MsgBox("Hello", MsgBoxStyle.OkOnly + MsgBoxStyle.Information, "Button")
End Sub
End Class
Output:

EXERCISE:

1. Write a program to perform the arithmetic operations using controls label,


button & textbox.

Design screen:
Program:
Public Class Form1
Private Sub Button1_Click(sender As Object, e As EventArgs) Handles Button1.Click
Dim a, b, c As Integer
a = TextBox1.Text
b = TextBox2.Text
c=a+b
TextBox3.Text = c

End Sub

Private Sub Button5_Click(sender As Object, e As EventArgs) Handles Button5.Click


Dim a, b, c As Integer
a = TextBox1.Text
b = TextBox2.Text
c = a Mod b
TextBox3.Text = c

End Sub

Private Sub Button4_Click(sender As Object, e As EventArgs) Handles Button4.Click


Dim a, b, c As Integer
a = TextBox1.Text
b = TextBox2.Text
c=a/b
TextBox3.Text = c

End Sub

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


Dim a, b, c As Integer
a = TextBox1.Text
b = TextBox2.Text
c=a-b
TextBox3.Text = c

End Sub

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


Dim a, b, c As Integer
a = TextBox1.Text
b = TextBox2.Text
c=a*b
TextBox3.Text = c
End Sub

Private Sub Button6_Click(sender As Object, e As EventArgs) Handles Button6.Click


TextBox1.Clear()
TextBox2.Clear()
TextBox3.Clear()
End Sub
End Class

Output:
2. Write a program to change the background color of the form when user
clicks on different button.

Design screen:

Program:
Public Class EXERCISE2
Private Sub Button1_Click(sender As Object, e As EventArgs) Handles Button1.Click
Me.BackColor = Color.Red
End Sub

Private Sub Button7_Click(sender As Object, e As EventArgs) Handles Button7.Click


Me.BackColor = Color.White
End Sub

Private Sub Button4_Click(sender As Object, e As EventArgs) Handles Button4.Click


Me.BackColor = Color.Blue
End Sub

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


Me.BackColor = Color.Yellow
End Sub

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


Me.BackColor = Color.Green
End Sub

Private Sub Button5_Click(sender As Object, e As EventArgs) Handles Button5.Click


Me.BackColor = Color.Pink
End Sub

Private Sub Button6_Click(sender As Object, e As EventArgs) Handles Button6.Click


Me.BackColor = Color.Black
End Sub
End Class

Output:

After click on red button


After click on blue button

After click on yellow button


Practical No-9

Aim: Design windows application using radio button & check box
Design screen:

Program:
Public Class Form1
Private Sub Form1_Load(sender As Object, e As EventArgs) Handles MyBase.Load
RadioButton1.Checked = True
End Sub

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


If RadioButton1.Checked = True Then
MsgBox("English is selected")
Exit Sub
ElseIf RadioButton2.Checked = True Then
MsgBox("Hindi is selected")
Exit Sub
Else
MsgBox("Marathi is selected")
Exit Sub
End If
End Sub

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


Dim s As String = ""
If CheckBox1.checked = True Then
s = " CPP"
End If
If CheckBox2.Checked = True Then
s = s & " JAVA"
End If
If CheckBox3.checked = True Then
s = s & " SEN"
End If
If CheckBox4.Checked = True Then
s = s & " MIC"
End If
If CheckBox5.Checked = True Then
s = s & " DBMS"
End If

If s.Length > 0 Then


MsgBox(s & " is selected")
Else
MsgBox("no check box selected")
End If
CheckBox1.ThreeState = True
End Sub
End Class
Output:
Practical Related Questions:

1. Write a program using radio button to change the bulb state ON/OFF.

Design screen:

Program:
Public Class practrelated1
Private Sub RadioButton1_CheckedChanged(sender As Object, e As EventArgs) Handles
RadioButton1.CheckedChanged
PictureBox1.Show()
PictureBox2.Hide()
End Sub
Private Sub RadioButton2_CheckedChanged(sender As Object, e As EventArgs) Handles
RadioButton2.CheckedChanged
PictureBox1.Hide()
PictureBox2.Show()
End Sub

Private Sub practrelated1_Load(sender As Object, e As EventArgs) Handles MyBase.Load


PictureBox1.Hide()
PictureBox2.Hide()
End Sub
End Class
Output:
EXERCISE:

1. Write a program to change the forecolor of the text in label(use different


radio buttons for colors i.e. red, green, blue)

Design screen:

Program:
Public Class Form2
Private Sub RadioButton3_CheckedChanged(sender As Object, e As EventArgs) Handles
RadioButton3.CheckedChanged
Label1.ForeColor = Color.Yellow
End Sub

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


RadioButton1.CheckedChanged
Label1.ForeColor = Color.Red
End Sub

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


RadioButton2.CheckedChanged
Label1.ForeColor = Color.Blue
End Sub

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


RadioButton4.CheckedChanged
Label1.ForeColor = Color.Green
End Sub

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


RadioButton5.CheckedChanged
Label1.ForeColor = Color.Pink
End Sub
End Class

Output:
Practical No-10

Aim:Design windows application using List Box & Combo Box

Design screen:

Program:
Public Class Form1
Private Sub Form1_Load(sender As Object, e As EventArgs) Handles MyBase.Load
ListBox1.Items.Add("sunday")
ListBox1.Items.Add("monday")
ListBox1.Items.Add("tuesday")
ListBox1.Items.Add("wednesday")
ListBox1.Items.Add("thursday")
ListBox1.Items.Add("friday")
ListBox1.Items.Add("saturday")
ListBox1.SelectionMode = SelectionMode.One

ComboBox1.Items.Add("week days")
ComboBox1.Items.Add("year")

End Sub

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


Dim obj As Object
For Each obj In ListBox1.SelectedItems
MsgBox(obj.ToString & " is selected")
Next
End Sub

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


ComboBox1.SelectedIndexChanged
ComboBox2.Items.Clear()
If ComboBox1.SelectedItem = "week days" Then
ComboBox2.Items.Add("monday")
ComboBox2.Items.Add("tuesday")
ComboBox2.Items.Add("wednesday")
Else ComboBox1.SelectedItem = "Year"
ComboBox2.Items.Add("2000")
ComboBox2.Items.Add("2002")
ComboBox2.Items.Add("2004")
ComboBox2.Items.Add("2006")
End If
End Sub
End Class

Output:
Practical Related Questions:

1. Write a program to select multiple subjects using list box control.

Design screen:

Program:
Public Class practrelated1
Private Sub practrelated1_Load(sender As Object, e As EventArgs) Handles MyBase.Load
ListBox1.Items.Add("JAVA")
ListBox1.Items.Add("CPP")
ListBox1.Items.Add("OOP")
ListBox1.Items.Add("DBMS")
ListBox1.Items.Add("MIC")
ListBox1.Items.Add("GAD")
ListBox1.Items.Add("SEN")
ListBox1.SelectionMode = SelectionMode.MultiSimple
End Sub

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


Dim obj As Object
For Each obj In ListBox1.SelectedItems
MsgBox(obj.ToString & " is selected")
Next
End Sub
End Class
Output:
2. Write a program to select colleges using single combo box.

Design screen:

Program:
Public Class practrelated2
Private Sub practrelated2_Load(sender As Object, e As EventArgs) Handles MyBase.Load
ComboBox1.Items.Add("GOVERNMENT POLYTECHNIC AWASARI(KH)")
ComboBox1.Items.Add("GOVERNMENT POLYTECHNIC PUNE")
ComboBox1.Items.Add("PIMPRI CHINCHWAD POLYTECHNIC COLLEGE")
ComboBox1.Items.Add("INDIRA GANDHI POLYTECHNIC BELWANDI")
ComboBox1.Items.Add("GOVERNMENT POLYTECHNIC AHMEDNAGAR")
End Sub
End Class

Output:
EXERCISE:

1. Implement a program for student registration which will allow the student to
register for multiple subjects for single semester using list & combo box.

Design screen:

Program:
Public Class pract10_exercise
Private Sub pract10_exercise_Load(sender As Object, e As EventArgs) Handles
MyBase.Load
ComboBox1.Items.Add("1st Semester")
ComboBox1.Items.Add("2nd Semester")
ComboBox1.Items.Add("3rd Semester")
ComboBox1.Items.Add("4th Semester")
End Sub
Private Sub ComboBox1_SelectedIndexChanged(sender As Object, e As EventArgs) Handles
ComboBox1.SelectedIndexChanged
If ComboBox1.SelectedIndex = 0 Then
ListBox1.Items.Add("ENGLISH")
ListBox1.Items.Add("PHYSICS")
ListBox1.Items.Add("CHEMESTRY")
ListBox1.Items.Add("MATHEMATICS")
End If
If ComboBox1.SelectedIndex = 1 Then
ListBox1.Items.Clear()
ListBox1.Items.Add("ELEMENTS OF ELECTRICAL ENGINEERING")
ListBox1.Items.Add("APPLIED MATHEMATICS")
ListBox1.Items.Add("BASIC ELECRONICS")
ListBox1.Items.Add("PROGRAMMING IN C")
End If
If ComboBox1.SelectedIndex = 2 Then
ListBox1.Items.Clear()
ListBox1.Items.Add("OOP")
ListBox1.Items.Add("DATA STRUCTURE")
ListBox1.Items.Add("PRINCIPLE OF DATABASE")
ListBox1.Items.Add("DATA COMMUNICATION")
ListBox1.Items.Add("DT AND MICROPROCCESSOR")
ListBox1.Items.Add("MULTIMEDIA TECHNIQUES")
End If
If ComboBox1.SelectedIndex = 3 Then
ListBox1.Items.Clear()
ListBox1.Items.Add("JAVA")
ListBox1.Items.Add("SOFTWARE ENGG")
ListBox1.Items.Add("DATABASE MANAGEMENT")
ListBox1.Items.Add("COMPUTER NETWORK")
ListBox1.Items.Add("GUI APPLICATION DEVELOPMENT")
End If
End Sub
End Class
Output:
Practical No.11
Aim:Design Windows apllication using picture Box and pannel.

Program:

Public Class Form1


Private Sub Form1_Load(sender As Object, e As EventArgs) Handles MyBase.Load
PictureBox1.Image = Image.FromFile("C:\Users\Tejal Sawant\Desktop\flower.jpeg")
PictureBox1.SizeMode = PictureBoxSizeMode.Zoom
End Sub

Private Sub Panel1_Paint(sender As Object, e As PaintEventArgs) Handles Panel1.Paint

End Sub

Private Sub Panel2_Paint(sender As Object, e As PaintEventArgs) Handles Panel2.Paint

End Sub

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


If RadioButton1.Checked = True Then
MsgBox("Pink is selected")
Exit Sub
Else
MsgBox("Red is selected")
Exit Sub
End If

End Sub

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


If RadioButton3.Checked = True Then
MsgBox("Yellow is selected")
Exit Sub
Else
MsgBox("White is selected")
Exit Sub
End If
End Sub
End Class
Design Screen:

Output:

Exercise:

1]Write a program Using PictureBox control to load an image at Run time.

Program:

Public Class Form1


Private Sub Button1_Click(sender As Object, e As EventArgs) Handles Button1.Click
PictureBox1.Image = Image.FromFile("C:\Users\Tejal Sawant\Desktop\flower.jpeg")
PictureBox1.SizeMode = PictureBoxSizeMode.Zoom
End Sub
End Class

Design Screen:

Output:
2]Write a program To demostrate use of panel control in vb.net.

Program:

Public Class Form1


Private Sub Button1_Click(sender As Object, e As EventArgs) Handles Button1.Click
Panel1.BackColor = Color.Pink

End Sub

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


Me.Close()
End Sub
End Class

Design screen:
Output:
Practical No 12

Aim:Design Windows application using tab control and Timer.


Tab Control:

Progarm:
Public Class Form1
Private Sub Button1_Click(sender As Object, e As EventArgs) Handles Button1.Click
If TextBox1.Text = "Tejalsawale331@gmail.com" Then
MsgBox("Mail ID submitted")
Else
MsgBox("Wrong mail Id")
End If
End Sub

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


If RadioButton1.Checked = True Then
MsgBox("Java is Selected")
Else
MsgBox("Vb.net is Selected")
End If
End Sub
End Class

Design Screen:
Output Screen:
Timer:

Program:
Public Class Form1
Dim m As Integer = 0
Dim s As Integer = 0
Dim m1 As Integer = 0
Private Sub Form1_Load(sender As Object, e As EventArgs) Handles MyBase.Load

End Sub

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


m1 += 1
Label1.Text = m & " : " & s & " : " & m1
If m1 = 11 Then
m1 = 0
s += 1

Label1.Text = m & " : " & s & " : " & m1

End If
If s = 60 Then
m1 = 0
s += 1

Label1.Text = m & " : " & s & " : " & m1

If m = 60 Then
Timer1.Stop()
m=0
s=0
m1 = 0
Label1.Text = m & " : " & s & " : " & m1
End If
End If

End Sub

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


Timer1.Start()
End Sub

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


Timer1.Stop()
End Sub
Private Sub Button3_Click(sender As Object, e As EventArgs) Handles Button3.Click
Timer1.Stop()
m=0
s=0
m1 = 0
Label1.Text = m & " : " & s & " : " & m1
End Sub
End Class

Design Screen:

Output Screen:
Exercise:

1] Write a program To demostrate use of Tab Control in vb.net.


Program:
Public Class Form1
Private Sub Button1_Click(sender As Object, e As EventArgs) Handles Button1.Click

MsgBox("You Have Registered Successfully")

End Sub

Private Sub Form1_Load(sender As Object, e As EventArgs) Handles MyBase.Load


ComboBox1.Items.Add("Male")
ComboBox1.Items.Add("female")
End Sub

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


If RadioButton1.Checked Then
MsgBox("C++ is selected")
End If
If RadioButton2.Checked Then
MsgBox("Java is selected")
End If
If RadioButton3.Checked Then
MsgBox("DBMS is selected")
End If
If RadioButton4.Checked Then
MsgBox("HTML is selected")
End If
If RadioButton5.Checked Then
MsgBox("PHP is selected")
End If
If RadioButton6.Checked Then
MsgBox("JavaScript is selected")
End If
If RadioButton7.Checked Then
MsgBox("Python is selected")
End If
If RadioButton8.Checked Then
MsgBox("DTM is selected")
End If

End Sub

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


Me.Close()
End Sub
End Class

Design Screen:

Output:
Practical No. 13 & 14

Aim: Write a program to perform validation using regular expression and error
provider.

Design Screen:

Program:
Imports System.Text.RegularExpressions
Public Class Form1
Private Sub Button1_Click(sender As Object, e As EventArgs) Handles Button1.Click
If Not IsNumeric(Me.TextBox2.Text) Then
Me.ErrorProvider1.SetError(Me.TextBox2, "Not allowed string")
Return
Else
Me.ErrorProvider1.SetError(Me.TextBox2, "")
MsgBox("Submitted")
End If
End Sub

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


TextBox1.TextChanged
Dim exp As New Regex("^[a-zA-Z]")
If exp.IsMatch(TextBox1.Text) Then
ErrorProvider1.SetError(sender, "")
Else
ErrorProvider1.SetError(sender, "Not Allowed Number")
End If

End Sub
End Class

Output Screen:
Prcatical No. 15

Aim: Implement a windows application using sub-procedures and parameterizedsub procedure.

Program:
Public Class Form1

Private Sub Button1_Click(ByVal sender As System.Object, ByVal e As System.EventArgs)


Handles Button1.Click
hello()
End Sub

Sub hello()
MessageBox.Show("Hello world")
End Sub
End Class

Design Screen:
Output Screen:

Area of Rectangle:

Program:
Module Module1
Sub Areaofrectangle(ByRef length As Double, ByRef width As Decimal)
Dim Area As Double
Area = length * width

Console.WriteLine("Total Pay: {0}", Area)


End Sub
Sub Main()
'calling the CalculatePay Sub Procedure
Areaofrectangle(12, 10)
Areaofrectangle(56, 20)
Areaofrectangle(32, 30)
Console.ReadLine()
End Sub

End Module
Output:
Practical No. 16

Aim:Implement program To demostrate use of simple function and parameterized function.

Program:
Module Module1

Function FindMax(ByVal n1 As Integer, ByVal n2 As Integer) As Integer


' local variable declaration */
Dim result As Integer

If (n1 > n2) Then


result = n1
Else
result = n2
End If
FindMax = result
End Function
Sub Main()
Dim a As Integer = 10
Dim b As Integer = 50
Dim res As Integer

res = FindMax(a, b)
Console.WriteLine("Max value is : {0}", res)
Console.ReadLine()
End Sub
End Module

Output:
Practical No. 17

Aim:Understand the concept of classes and object of Class.

Program:
Module Module1
Class Figure
Public len As Double
Public breadth As Double
End Class
Sub Main()
Dim Rectangle As Figure = New Figure()
Dim Area As Double = 0.0
Rectangle.len = 20.0
Rectangle.breadth = 14.0
area = Rectangle.len * Rectangle.breadth
Console.WriteLine("Area of Rectangle is : {0}", area)

Console.ReadKey()
End Sub
End Module

Output:
Practical No. 18

Aim:Implement a program for class constructor and Destructor to De-allocate Memory.

Progam:
Module Module1
Class Line
Private length As Double ' Length of a line
Public Sub New() 'parameterised constructor
Console.WriteLine("Object is being created")
End Sub
Protected Overrides Sub Finalize() ' destructor
Console.WriteLine("Object is being deleted")
Console.ReadKey()
End Sub
Public Sub setLength(ByVal len As Double)
length = len
End Sub

Public Function getLength() As Double


Return length
End Function
End Class
Sub Main()
Dim line As Line = New Line()
'set line length
line.setLength(6.0)
Console.WriteLine("Length of line : {0}", line.getLength())
Console.ReadKey()
End Sub

End Module
Output:
Practical No. 19

Aim:Develop a program for inheritance.

Program:
Module Module1
Class laptop 'Base Class
Private ram As Integer
Private hdd As Integer

Sub input_laptop()
Console.WriteLine("Enter the RAM and HDD value:")
ram = Console.ReadLine()
hdd = Console.ReadLine()
End Sub
Sub Display()
Console.WriteLine("RAM capacity is:" & ram)
Console.WriteLine("HDD capacity is:" & hdd)
End Sub
End Class

Class dell 'Derived Class


Inherits laptop
Private os As String
Sub input_dell()
Console.WriteLine("What is the os of the laptop:")
os = Console.ReadLine()
End Sub
Sub display_config()
Display()
Console.WriteLine("OS is:" & os)
End Sub
End Class
Sub Main()
Dim ob As dell = New dell()
ob.input_laptop()
ob.input_dell()
ob.display_config()
Console.ReadKey()

End Sub

End Module
Output:
Practical No. 20 & 21

Aim: Develop Program to Demostrate method overloading and overriding

Program:
Method Overloading:
Module Module1
Public Class demo
Public Overloads Function add(ByVal a As Integer, ByVal b As Integer)
Console.WriteLine("You are in function add(a,b)")
Return a + b
End Function
Public Overloads Function add(ByVal a As Integer, ByVal b As Integer, ByVal c As
Integer)
Console.WriteLine("You are in function add(a, b, c)")
Return a + b + c
End Function
End Class
Sub Main()
Dim obj As New demo
Console.WriteLine(obj.add(4, 2))
Console.WriteLine(obj.add(4, 5, 1))
Console.WriteLine("press return to exit...")
Console.ReadLine()
End Sub

End Module

Output:
Method Overriding:

Module Module1
Class Over
Public Overridable Function add(ByVal x As Integer, ByVal y As Integer)
Console.WriteLine("Function Inside Base Class")
Return (x + y)
End Function
End Class
Class DerOver
Inherits Over
Public Overrides Function add(ByVal x As Integer, ByVal y As Integer)
Console.WriteLine(MyBase.add(120, 100))
Console.WriteLine("Function Inside Derived Class")
Return (x + y)
End Function
End Class
Sub Main()
Dim obj As New DerOver
Console.WriteLine(obj.add(10, 100))
Console.ReadLine()
End Sub

End Module

Output:
Practical No. 22

Aim: Develop program to demostrate Shawdowing in inheritance.

Program:

Module Module1

Sub Main()
Dim p As New parent
Dim c As New child
p.use()
c.use()
Console.WriteLine("________________________________")
p.disp()
c.disp()
Console.ReadLine()
End Sub
Public Class parent
Public Sub disp()
Console.WriteLine("Parent")
End Sub
Public Sub use()
Me.disp()
End Sub
End Class
Public Class child
Inherits parent
Public Shadows Sub disp()
Console.WriteLine("Child")
End Sub
End Class

End Module
Output:
Practical No. 23

Aim: Construct a program to handle run time error using Exception Handling.

Program:

Module Module1
Sub division(ByVal num1 As Integer, ByVal num2 As Integer)
Dim result As Integer
Try
result = num1 \ num2
Catch e As DivideByZeroException
Console.WriteLine("Exception caught: {0}", e)
Finally
Console.WriteLine("Result: {0}", result)
End Try
End Sub
Sub Main()
division(25, 0)
Console.ReadKey()
End Sub

End Module

Output:
Practical No. 24

Aim: Understand the concept of Ado.net.

Design Screen:

Program:

Imports System.Data.OleDb
Public Class Form1
Private Sub Button1_Click(sender As Object, e As EventArgs) Handles Button1.Click
Dim con As New OleDbConnection("Provider=Microsoft.ACE.OLEDB.12.0;Data
Source=C:\Users\Tejal Sawant\Documents\DBMS_practical\student_info.accdb")
Dim cmd As New OleDbCommand("select * from student", con)
Dim da As New OleDbDataAdapter(cmd)
Dim ds As New DataSet
Dim dt As New DataTable
ds.Tables.Add(dt)
da.Fill(dt)
con.Open()
DataGridView1.DataSource = dt.DefaultView
con.Close()
End Sub
End Class
Output Screen:
Practical No. 25 & 26

Aim: Understand Concept of data adapter.

Design Screen:

Program:

Imports System.Data.OleDb
Public Class Form1
Dim con As New OleDbConnection("Provider=Microsoft.ACE.OLEDB.12.0;Data
Source=C:\Users\Tejal Sawant\Documents\DBMS_practical\student_info.accdb")
Dim cmd As New OleDbCommand("select * from student", con)
Dim da As New OleDbDataAdapter(cmd)
Dim ds As New DataSet
Dim max As Integer
Dim min As Integer = 0
Private Sub Form1_Load(sender As Object, e As EventArgs) Handles MyBase.Load
con.Open()
da.Fill(ds, "student")
max = ds.Tables(0).Rows.Count
MsgBox(max)
navigate(min)
con.Close()
End Sub
Private Sub navigate(ByVal r As Integer)
TextBox1.Text = ds.Tables(0).Rows(r).Item(0)
TextBox2.Text = ds.Tables(0).Rows(r).Item(1)
TextBox3.Text = ds.Tables(0).Rows(r).Item(2)
End Sub

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


If min = 0 Then
MsgBox("You Are already at first Record")
Else
min = 0
navigate(min)
End If
End Sub

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


If min = 0 Then
MsgBox("You Are already at first Record")
Else
min -= 1
navigate(min)
End If
End Sub

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


If min = max - 1 Then
MsgBox("You Are already at Last Record")
Else
min += 1
navigate(min)
End If
End Sub

Private Sub Button4_Click(sender As Object, e As EventArgs) Handles Button4.Click


If min = max - 1 Then
MsgBox("You Are already at Last Record")
Else
min = max - 1
navigate(min)
End If
End Sub
End Class
Output Screen:
Practical No. 27

Aim: Understand the concept of select and insert data in database table

Design Screen:

Program:

Imports System.Data
Imports System.Data.OleDb
Public Class Form1
Dim con As New OleDbConnection("Provider=Microsoft.ACE.OLEDB.12.0;Data
Source=C:\Users\Tejal Sawant\Documents\DBMS_practical\student_info.accdb")
Dim cmd As OleDbCommand
Dim da As OleDbDataAdapter
Dim ds As New DataSet
Dim dt As New DataTable
Dim i As Integer = 0

Private Sub Form1_Load(sender As Object, e As EventArgs) Handles MyBase.Load


con.Open()
da = New OleDbDataAdapter("select *from student", con)
da.Fill(ds, "student")
navigate(i)
con.Close()
End Sub
Public Sub navigate(ByVal r As Integer)

TextBox1.Text = ds.Tables("student").Rows(r)("ID")
TextBox2.Text = ds.Tables("student").Rows(r)("Fname")
TextBox3.Text = ds.Tables("student").Rows(r)("Lname")
End Sub

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


If TextBox1.Text = "" Then
MsgBox("Please Enter data")
Exit Sub
End If
Try
cmd = New OleDbCommand("insert into student(ID,Fname,Lname) values(" &
TextBox1.Text & ",'" & TextBox2.Text & "','" & TextBox3.Text & "')", con)
con.Open()
i = cmd.ExecuteNonQuery()
If i > 0 Then
MsgBox("Record Inserted")
Else
MsgBox("Record Not Inserted")
End If
con.Close()
Catch ex As Exception
MsgBox("Error")
i = cmd.ExecuteNonQuery()
con.Close()
End Try
End Sub

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


con.Open()
cmd = New OleDbCommand("update student set Fname='" & TextBox2.Text &
"',Lname='" & TextBox3.Text & "' where ID=" & TextBox1.Text & " ", con)
cmd.ExecuteNonQuery()
MsgBox("Records Updated successfully")
con.Close()
End Sub

Private Sub Button5_Click(sender As Object, e As EventArgs) Handles Button5.Click


clear()
End Sub
Sub clear()
TextBox1.Clear()
TextBox2.Clear()
TextBox3.Clear()
TextBox1.Focus()
End Sub

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


con.Open()
cmd = New OleDbCommand("delete from student where ID=" & TextBox1.Text & " ",
con)
cmd.ExecuteNonQuery()
MsgBox("Records Deleted successfully")
ds.Clear()
da = New OleDbDataAdapter("select * from student order by ID", con)
da.Fill(ds, "student")
navigate(i)
con.Close()
End Sub

End Class

Output Screen:
Practical No. 28,29 & 30

Aim: Implement The concept of Data Binding.

Design Screen:

Output Screen:
Practical No. 31

Aim: Design a program to navigate Across Existing Data in table.

Design Screen:

Output Screen:
Practical No. 32

Aim: Develop An Executable file and Deploy it.

Design Screen:

Program:

Public Class Form1


Private Sub Button1_Click(sender As Object, e As EventArgs) Handles Button1.Click
If (OpenFileDialog1.ShowDialog = DialogResult.OK) Then
RichTextBox1.Text =
My.Computer.FileSystem.ReadAllText(OpenFileDialog1.FileName)
End If
End Sub
End Class
Output Screen:

You might also like