You are on page 1of 28

Roll No.

34 Name: Ujjawal Dewangan


EXPERIMENT NO. 1
AIM: Write a program in visual basic to design a identity card containing information regarding
students such as Name, Roll Number, Address, Course, Date of Birth, Blood Group, Phone
Number etc. Add an Exit Button.

Tools: Text Box, Label, Command Button

Coding: -
Private Sub Form_Load()

End Sub
Private Sub Command1_Click(Index As Integer)
Text1.Text = "Ujjawal Dewangan "
Text2.Text = 300102217155#
Text3.Text = 19
Text4.Text = "Male"
Text5.Text = "O+"
Text6.Text = "22/11/1999"
End Sub

Output:

1 Date: 02-Jan-2019
Roll No. 34 Name: Ujjawal Dewangan
EXPERIMENT NO. 2
AIM: Write a program in visual basic to design a Temperature Conversion application

Tools: Text Box, Label, Command Button,

Coding: - Dim f As Integer


Dim c As Integer

Private Sub Command1_Click()


c = Text2.Text
f = 9 * c / 5 + 32
Text1.Text = f
End Sub

Private Sub Command2_Click()


f = Text1.Text
c = (f - 32) * 5 / 9
Text2.Text = c
End Sub
Output:

2
Date: 08-Feb-2019
Roll No. 34 Name: Ujjawal Dewangan
EXPERIMENT NO. 3
AIM : Write a program in visual basic to design a Simple Calculator

Tools: Text Box, Label, Command Button,

Coding:- Dim a As Integer


Dim b As Integer
Dim c As Double
Private Sub Command1_Click()
a = Text1.Text
b = Text2.Text
c=a+b
Text3.Text = c
End Sub

Private Sub Command2_Click()


a = Text1.Text
b = Text2.Text
c=a-b
Text4.Text = c
End Sub

Private Sub Command3_Click()


a = Text1.Text
b = Text2.Text
c=a*b
Text5.Text = c
End Sub

Private Sub Command4_Click()


a = Text1.Text
b = Text2.Text
c=a/b
Text6.Text = c
End Sub

3
Date: 08-Jan-2019
Output :

4
Date: 08-Jan-2019
Roll No. 34 Name: Ujjawal Dewangan
EXPERIMENT NO. 4
AIM : Write a program in visual basic to design an application to find Factorial

Tools: Text Box, Label, Command Button,

Coding:- Dim fact As Double


Dim i As Integer

Private Sub Command1_Click()


fact = 1
For i = 1 To Val(Text1.Text) Step 1
fact = fact * i
Next i
Text2.Text = fact
End Sub

Private Sub Form_Load()


fact = 1
End Sub

Output :

5
Date: 15-Jan-2019
Roll No. 34 Name: Ujjawal Dewangan
EXPERIMENT NO. 5
AIM : Write a program in visual basic to design an application to find Multiplication table

Tools: Text Box, Label, Command Button

Coding:- Dim i As Integer

Private Sub Command1_Click()


List1.Clear
For i = 1 To Val(Text2.Text) Step 1
List1.AddItem (Val(Text1.Text) & " * " & i & " = " & Val(Text1.Text) * i)
Next i
End Sub

Output :

6
Date: 15-Jan-2019
Roll No. 34 Name: Ujjawal Dewangan
EXPERIMENT NO. 6
AIM : Write a program in visual basic to design an application to find Even or Odd Identifier

Tools: Text Box, Label, Command Button

Coding:- Private Sub Command1_Click()


If Val(Text1.Text) Mod 2 = 0 Then
Text2.Text = "Even"
Else
Text2.Text = "Odd"
End If
End Sub

Output :

7
Date: 15-Jan-2019
Roll No. 34 Name: Ujjawal Dewangan
EXPERIMENT NO. 7
AIM : Write a program in visual basic to design an image switching application.

Tools: Image box, label

Coding:-
Dim indicator As Integer

Private Sub Image1_Click()


Image2.Visible = True
Image1.Visible = False
indicator = 1
End Sub

Private Sub Image2_Click()


If indicator = 1 Then
Image3.Visible = True
Image2.Visible = False
Else
Image2.Visible = False
Image1.Visible = True
End If
End Sub

Private Sub Image3_Click()


If indicator = 1 Then
Image4.Visible = True
Image3.Visible = False
Else
Image2.Visible = True
Image3.Visible = False
End If
End Sub

Private Sub Image4_Click()


Image3.Visible = True
Image4.Visible = False
indicator = 4
End Sub

8
Date: 15-Jan-2019
Output :

9
Date: 15-Jan-2019
Roll No. 34 Name: Ujjawal Dewangan
EXPERIMENT NO. 8
AIM : Write a program in visual basic to design an application of Name-Sirname Separator

Tools: Text Box, Label, Command Button, Timer, Lists, Combo Box

Coding:- Private Sub Command1_Click()


a = Text4.Text
n = Len(a)
x = InStr(1, a, " ")
z=1
While InStr(z, a, " ")
y = InStr(z, a, " ")
z=y+1
Wend

Text1.Text = Left(a, x)
Text2.Text = Mid(a, x + 1, y - x - 1)
Text3.Text = Mid(a, y + 1, n - y)
End Sub
Output :

10
Date: 29-Jan-2019
Roll No. 34 Name: Ujjawal Dewangan
EXPERIMENT NO. 9
AIM : Write a program in visual basic to design an application of Swapping items between lists

Tools: Text Box, Label, Command Button, Timer, Lists, Combo Box

Coding:- Dim b As String


Dim c, i As Integer

Private Sub Combo1_Click()


List1.AddItem (Combo1.Text)
Combo1.RemoveItem (Combo1.ListIndex)
End Sub

Private Sub Command1_Click()


b = List1.Text
List1.RemoveItem (List1.ListIndex)
List2.AddItem (b)
End Sub

Private Sub Command2_Click()


b = List2.Text
List2.RemoveItem (List2.ListIndex)
List1.AddItem (b)
End Sub

Private Sub Command3_Click()


c = List1.ListCount
For i = 0 To c - 1
b = List1.List(i)
List2.AddItem (b)
Next
List1.Clear
End Sub

Private Sub Command4_Click()


c = List2.ListCount
For i = 0 To c - 1
b = List2.List(i)
List1.AddItem (b)
Next
List2.Clear
End Sub

11
Date: 29-Jan-2019
Output :

12
Date: 29-Jan-2019
Roll No. 34 Name: Ujjawal Dewangan
EXPERIMENT NO. 10
AIM : Write a program in visual basic to design an application of Stopwatch using Timer tool

Tools: Text Box, Label, Command Button, Timer

Coding:- Dim a As String

Private Sub Command1_Click()


Timer1.Enabled = True
End Sub

Private Sub Command2_Click()


Timer1.Enabled = False
End Sub

Private Sub Command3_Click()


a = a & Label4.Caption & ":" & Label3.Caption & ":" & Label2.Caption & ":" &
Label13.Caption & vbNewLine
Text1.Text = a
End Sub

Private Sub Command4_Click()


Label13.Caption = "00"
Label3.Caption = "00"
Label2.Caption = "00"
Label4.Caption = "00"
Text1.Text = " "
a=""
End Sub

Private Sub Form_Load()


Timer1.Enabled = False
End Sub

Private Sub Timer1_Timer()


Label13.Caption = Label13.Caption + 1
If Label13.Caption = 100 Then
Label2.Caption = Label2.Caption + 1
Label13 = 0
If Label2.Caption = 60 Then
Label3.Caption = Label3.Caption + 1
Label2.Caption = 0
If Label3.Caption = 60 Then
13
Date: 05-Feb-2019
Label4.Caption = Label4.Caption + 1
Label3.Caption = 0
End If
End If
End If
End Sub

Output :

14
Date: 05-Feb-2019
Roll No. 34 Name: Ujjawal Dewangan
EXPERIMENT NO. 11
AIM : Write a program in visual basic to design an application of Text Formatting using Lists

Tools: Text Box, Label, Command Button, Timer, Lists, Radio Button, Check Box, Frame

Coding:- Private Sub Check1_Click()


Text1.FontBold = Check1.Value
End Sub
Private Sub Check3_Click()
Text1.FontUnderline = Check3.Value
End Sub
Private Sub Check2_Click()
Check2.FontItalic = Check2.Value
End Sub
Private Sub Check4_Click()
Text1.FontStrikethru = Check4.Value
End Sub
Private Sub Option1_Click()
Text1.BackColor = &HC000C0
End Sub
Private Sub Option10_Click()
Text1.ForeColor = &HFF00FF
End Sub
Private Sub Option11_Click()
Text1.FontName = "Comic Sans MS"
End Sub
Private Sub Option12_Click()
Text1.FontName = "Arial Narrow"
End Sub
Private Sub Option13_Click()
Text1.FontName = "MS Sans Serif"
End Sub
Private Sub Option14_Click()
Text1.FontName = "Segoe Script"
End Sub
Private Sub Option15_Click()
Text1.FontName = "Monotype Corsiva"
End Sub
Private Sub Option2_Click()
Text1.BackColor = &H80FF&
End Sub
Private Sub Option3_Click()
Text1.BackColor = &HFF80FF
End Sub
15
Date: 05-Feb-2019
Private Sub Option4_Click()
Text1.BackColor = &HFFFF80
End Sub
Private Sub Option5_Click()
Text1.BackColor = &H808080
End Sub
Private Sub Option6_Click()
Text1.ForeColor = &HFF&
End Sub
Private Sub Option7_Click()
Text1.ForeColor = &HFF00&
End Sub
Private Sub Option8_Click()
Text1.ForeColor = &HFF0000
End Sub
Private Sub Option9_Click()
Text1.ForeColor = 65535
End Sub
Output :

16
Date: 05-Feb-2019
Roll No. 34 Name: Ujjawal Dewangan
EXPERIMENT NO. 12
AIM : Write a program in visual basic to design an application of Running Letters

Tools: Label, Timer

Coding:- Dim a As String


Dim i As Integer
Dim l As Integer
Private Sub Form_Load()
a = Label2.Caption
l = Len(a)
i=0
End Sub
Private Sub Timer1_Timer()
Label2.Caption = Mid(a, 1, i)
i=i+1
If i = l Then
i=0
End If
End Sub
Output :

17
Date: 05-Feb-2019
Roll No. 34 Name: Ujjawal Dewangan
EXPERIMENT NO. 12
AIM : Write a program in visual basic to design an application to show details of personalities using
combo box and lists.

Tools: Text Box, Label, Command Button, Image box, Lists, Combo Box, Frame

Coding:- Private Sub Combo1_CLick()


List1.Clear
If Combo1.Text = "Actor" Then
List1.AddItem ("Amitabh Bachhan")
List1.AddItem ("Manoj Vajpai")
List1.AddItem ("Nawazudin Siddiqui")

ElseIf Combo1.Text = "Actress" Then


List1.AddItem ("Kriti Kharabanda")
List1.AddItem ("Kriti Sanon")
List1.AddItem ("Taapse Paanu")

ElseIf Combo1.Text = "Comedian" Then


List1.AddItem ("Rajpal Yadav")
List1.AddItem ("Kapil Sharma")
List1.AddItem ("Paresh Rawal")
End If
End Sub

Private Sub List1_Click()


If Combo1.Text = "Actor" Then
If List1.ListIndex = 0 Then
Frame1.Caption = List1.List(List1.ListIndex)
Image1.Picture = LoadPicture("D:\0.jpg")
Label5.Caption = "Amitabh Bachchan is an Indian film actor, film producer, television
host, occasional playback singer and former politician."
Text1.Text = "11 October 1942"
Text2.Text = "185 cm"
Text3.Text = "Anand, Zanzeer, Piku, Paa, 101 Not Out"

ElseIf List1.ListIndex = 1 Then


Frame1.Caption = List1.List(List1.ListIndex)
Image1.Picture = LoadPicture("D:\1.jpg")
Label5.Caption = "Manoj Bajpayee (born 23 April 1969), also credited as Manoj Bajpai,
is an Indian film actor who predominantly works in Hindi cinema and has also done Telugu
and Tamil language films."
Text1.Text = "23 April 1969"

18
Date: 12-Feb-2019
Text2.Text = "178 cm"
Text3.Text = "Jail, Satyamev Jayate, Gangs of Wassepur"

ElseIf List1.ListIndex = 2 Then


Frame1.Caption = List1.List(List1.ListIndex)
Image1.Picture = LoadPicture("D:\2.jpg")
Label5.Caption = "Nawazuddin Siddiqui (born 19 May 1974) is an Indian actor, known
for his works in Hindi cinema.[1][5] An alumnus of the National School of Drama, Siddiqui's
breakthrough role was with Anurag Kashyap's Black Friday."
Text1.Text = "19 May 1974 "
Text2.Text = "168 cm"
Text3.Text = "Haramkhor, Freaky Ali, Gangs of Wassepur"
End If
ElseIf Combo1.Text = "Actress" Then
If List1.ListIndex = 0 Then
Frame1.Caption = List1.List(List1.ListIndex)
Image1.Picture = LoadPicture("D:\0.png")
Label5.Caption = "Kriti Kharbanda (born 29 October 1988) is an Indian film actress and
Model. Best known for her work in the Kannada and the Telugu film industries."
Text1.Text = "11 October 1942"
Text2.Text = "185 cm"
Text3.Text = "Anand, Zanzeer, Piku, Paa, 101 Not Out"

ElseIf List1.ListIndex = 1 Then


Frame1.Caption = List1.List(List1.ListIndex)

Image1.Picture = LoadPicture("D:\1.jpg")
Label5.Caption = "Kriti Sanon (born 27 July 1990) is an Indian actress who appears
predominantly in Hindi films. Born and raised in New Delhi, she pursued an engineering
degree from the Jaypee Institute of Information Technology."
Text1.Text = "23 April 1969"
Text2.Text = "178 cm"
Text3.Text = "Jail, Satyamev Jayate, Gangs of Wassepur"

ElseIf List1.ListIndex = 2 Then


Frame1.Caption = List1.List(List1.ListIndex)

Image1.Picture = LoadPicture("D:\2.jpg")
Label5.Caption = "Taapsee Pannu (born 1 August 1987) is an Indian actress known for
her work in Telugu, Tamil, Malayalam and Hindi films. Taapsee worked as a software
professional and pursued a career in modelling before becoming an actress."
Text1.Text = "19 May 1974 "
Text2.Text = "168 cm"
Text3.Text = "Haramkhor, Freaky Ali, Gangs of Wassepur"
End If
19
Date: 12-Feb-2019
ElseIf Combo1.Text = "Comedian" Then
If List1.ListIndex = 0 Then
Image1.Picture = LoadPicture("D:\0.png")
Label5.Caption = "Amitabh Bachchan is an Indian film actor, film producer, television
host, occasional playback singer and former politician."
Text1.Text = "11 October 1942"
Text2.Text = "185 cm"
Text3.Text = "Anand, Zanzeer, Piku, Paa, 101 Not Out"

ElseIf List1.ListIndex = 2 Then


Image1.Picture = LoadPicture("D:\2.jpg")
Label5.Caption = "Nawazuddin Siddiqui (born 19 May 1974) is an Indian actor, known
for his works in Hindi cinema.[1][5] An alumnus of the National School of Drama, Siddiqui's
breakthrough role was with Anurag Kashyap's Black Friday."
Text1.Text = "19 May 1974 "
Text2.Text = "168 cm"
Text3.Text = "Haramkhor, Freaky Ali, Gangs of Wassepur"
End If
End If
End Sub

Output :

20
Date: 12-Feb-2019
Roll No. 34 Name: Ujjawal Dewangan
EXPERIMENT NO. 13
AIM : Write a program in visual basic to design an application to show details of personalities using
combo box and lists.

Tools: Text Box, Label, Command Button, Image box, Lists, Combo Box, Frame

Coding:- Dim c1 As Integer


Dim c2 As Integer

Private Sub File1_Click()


Image1.Picture = LoadPicture(File1.Path & "\" & File1.FileName)
End Sub

Private Sub Form_Load()


c1 = 0
c2 = 0
Timer1.Enabled = False
End Sub

Private Sub Command1_Click()


c1 = c1 + 1
If c1 Mod 2 = 0 Then
Command1.Caption = "FullScreen"

Image1.Width = 4800
Image1.Height = 3600
Image1.Top = 2760
Image1.Left = 9600

File1.Visible = True
Dir1.Visible = True
Drive1.Visible = True
Label1.Visible = True
Label2.Visible = True
Command2.Visible = True

Command1.Left = 9360
Command1.Top = 7200

Else
Command1.Caption = "EXIT FullScreen"

21
Date: 05-Mar-2019
Image1.Width = 21600
Image1.Height = 13500
Image1.Top = 0
Image1.Left = 0

File1.Visible = False
Dir1.Visible = False
Drive1.Visible = False
Label1.Visible = False
Label2.Visible = False
Command2.Visible = False

Command1.Left = 19065
Command1.Top = 12000

End If

End Sub

Private Sub Command2_Click()


c2 = c2 + 1
Dim count As Integer
If c2 Mod 2 = 0 Then
Command2.Caption = "Start"
Timer1.Enabled = False

Else
Command2.Caption = "Stop"
Timer1.Enabled = True
End If
End Sub

Private Sub Dir1_Change()


File1.Path = Dir1.Path
End Sub

Private Sub Drive1_Change()


Dir1.Path = Drive1.Drive
End Sub
Private Sub Timer1_Timer()
If File1.ListIndex = File1.ListCount - 1 Then
File1.ListIndex = 0
Else
File1.ListIndex = File1.ListIndex + 1
End If
End Sub
22
Date: 05-Mar-2019
Output :

23
Date: 05-Mar-2019
Roll No. 34 Name: Ujjawal Dewangan
EXPERIMENT NO. 14
AIM : Write a program in visual basic to design an application of Notepad

Tools: RichText Box, Common Dialog, Menu Editor

Coding:- Dim st As String


Dim st2 As String

Private Sub bc_Click()


cd.ShowColor
rt.BackColor = cd.Color
End Sub

Private Sub cpy_Click()


Clipboard.SetText (rt.SelText)
End Sub

Private Sub ct_Click()


Clipboard.SetText (rt.SelText)
rt.SelText = ""
End Sub

Private Sub del_Click()


rt.SelText = ""
End Sub

Private Sub e_Click()


rt.Text = "Exiited"
End Sub

Private Sub fc_Click()


cd.ShowColor
rt.SelColor = cd.Color
End Sub

Private Sub Form_Load()


ct.Enabled = False
cpy.Enabled = False
End Sub

Private Sub n_Click()


rt.Text = ""
End Sub

24
Date: 12-Mar-2019
Private Sub pst_Click()
rt.SelText = Clipboard.GetText
End Sub

Private Sub o_Click()


cd.ShowOpen
st = cd.FileName
rt.LoadFile (st)
End Sub

Private Sub rt_Click()


If rt.SelText <> "" Then
ct.Enabled = True
cpy.Enabled = True
End If
If rt.SelText = "" Then
ct.Enabled = False
cpy.Enabled = False
End If
End Sub

Private Sub s_Click()


cd.ShowSave
st = cd.FileName
rt.SaveFile (st)
End Sub
Output :

25
Date: 12-Mar-2019
Roll No. 34 Name: Ujjawal Dewangan
EXPERIMENT NO. 14
AIM : Write a program in visual basic to design an application using Database

Tools: Label, TextBox, Command Button, Database Connection

Coding:- Dim cn As New ADODB.Connection


Dim rs As New ADODB.Recordset

Private Sub Command1_Click()


cn.Open "ss"
rs.Open "select * from stud", cn, adOpenDynamic, adLockBatchOptimistic

Text1.Text = rs.Fields(0)
Text2.Text = rs.Fields(1)
Text3.Text = rs.Fields(2)
Text4.Text = rs.Fields(3)
Text5.Text = rs.Fields(4)
Text6.Text = rs.Fiels(5)
End Sub
Output :

26
Date: 26-Mar-2019
Roll No. 21 Name: Pranjalya Tiwari
EXPERIMENT NO. 14
AIM : Write a program in visual basic to design an application using Database

Tools: Label, TextBox, Command Button, Database Connection

Coding:- Dim cn As New ADODB.Connection


Dim rs As New ADODB.Recordset

Private Sub Command1_Click()


cn.Open "ss"
rs.Open "select * from stud", cn, adOpenDynamic, adLockBatchOptimistic

Text1.Text = rs.Fields(0)
Text2.Text = rs.Fields(1)
Text3.Text = rs.Fields(2)
Text4.Text = rs.Fields(3)
Text5.Text = rs.Fields(4)
Text6.Text = rs.Fiels(5)
End Sub
Output :

26
Date: 26-Mar-2019

You might also like