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

VB Lab Manual 2009-2010

This document is a lab manual for VB that contains instructions for creating various applications using different controls in VB. It includes sections on creating applications using text boxes, labels, command buttons, option buttons, check boxes, combo boxes, list boxes, data controls, grids, menus, scroll bars, and more. The document was prepared by Pavan Kumar. It provides code examples and explanations for creating forms and applications with different controls.

Uploaded by

Krutil Patel
Copyright
© © All Rights Reserved
We take content rights seriously. If you suspect this is your content, claim it here.
Available Formats
Download as DOC, PDF, TXT or read online on Scribd
0% found this document useful (0 votes)
77 views

VB Lab Manual 2009-2010

This document is a lab manual for VB that contains instructions for creating various applications using different controls in VB. It includes sections on creating applications using text boxes, labels, command buttons, option buttons, check boxes, combo boxes, list boxes, data controls, grids, menus, scroll bars, and more. The document was prepared by Pavan Kumar. It provides code examples and explanations for creating forms and applications with different controls.

Uploaded by

Krutil Patel
Copyright
© © All Rights Reserved
We take content rights seriously. If you suspect this is your content, claim it here.
Available Formats
Download as DOC, PDF, TXT or read online on Scribd
You are on page 1/ 24

VB Lab Manual 2009-2010

Contents
1. Generate one example using Text,Label,Command Button
ontrols and also !rite appropriate e"ents #or t$at
2. Create an %ppliation &sing 'ption Button and C$e( Boxes
). Create an appliation &sing *i##erent Combo and List Box
ontrols
+. Generate one example using *ata Control and also !rite
appropriate e"ents #or t$at
,. Create a Calulator %ppliation
-. Create an appliation using *i##erent Grid Controls
.. Generate one example !it$out using *ata Control
/. Create an appliation using 0ori1antal and Vertial 2roll Bars
9. Create an appliation using Menus
10.Create an appliation &sing M*3 #orm !it$ Toolbar ontrol
11. Create an %ppliation &sing *irListbox, *ri"eListbox , 4ile
Listbox ontrols
12.Create an appliation &sing 5opup Menus
1).Create an appliation &sing 2$ape and Timer ontrols


5repared b6 7.V.2. 5a"an 8umar
1. Generate One Example using Text,Label,Command Button controls and also write
appropriate events for tat
!rivate "ub cmd#Exit#Clic$%&
'nload (e
End "ub
!rivate "ub cmd#O$#Clic$%&
(sgBox ) *eg.+O, ) - txt#*eg+o.Text - ) +ame, ) - #
txt#name.Text - ) .ddress, ) - txt#address.Text - #
) Branc, ) - txt#Branc.Text
End "ub
!rivate "ub Lbl#(essage#/blClic$%&
(sgBox %) tis is a label to sow te events and messages)&
End "ub
!rivate "ub txt#.ddress#Lost0ocus%&
Lbl#(essage.Caption 1 )txt#.ddress#Lost0ocus event)
End "ub
!rivate "ub Txt#+ame#Cange%&
Lbl#(essage.Caption 1 )+o. of letters in name ,) - Len%txt#name.Text&
End "ub
!rivate "ub txt#*eg+o#Got0ocus%&
Lbl#(essage.Caption 1 )txt#*eg+o#Got0ocus event)
End "ub
2. Create .n .pplication 'sing Option Button and Cec$ Boxes
!rivate "ub Cmd#Calculate#Clic$%&
3f txt#Basic.Text 1 )) Ten
(sgBox %)Enter Basic )&
Exit "ub
End 3f
3f txt#/eductions.Text 1 )) Ten
(sgBox %)Enter /eductions)&
Exit "ub
End 3f
txt#/..Text 1 4al%txt#Basic.Text& 5 16
txt#T..Text 1 4al%txt#Basic.Text& 5 17
txt#8*..Text 1 4al%txt#Basic.Text& 5 26
txt#Gross!a9.Text 1 4al%txt#Basic.Text& : #
4al%txt#/..Text& : 4al%txt#8*..Text& : 4al%txt#T..Text&
txt#+et!a9.Text 1 4al%txt#Gross!a9& ; 4al%txt#/eductions&
End "ub
!rivate "ub cmd#Exit#Clic$%&
'nload (e
End "ub
!rivate "ub Cmd#+ew*ecord#Clic$%&
txt#Emp+ame.Text 1 ))
txt#Empno.Text 1 ))
txt#Basic.Text 1 ))
txt#/..Text 1 ))
txt#8*..Text 1 ))
txt#T..Text 1 ))
txt#Gross!a9.Text 1 ))
txt#/eductions.Text 1 ))
txt#+et!a9.Text 1 ))
End "ub
!rivate "ub 0orm#Load%&
(e.<indow"tate 1 2
End "ub
= Create an application 'sing /ifferent Combo and List Box controls
.
>. Generate one example using /ata Control and also write appropriate events for tat
7. Create a Calculator application
/im ? .s /ouble
/im @ .s /ouble
/im A .s /ouble
/im op .s 3nteger
/im f .s 3nteger
!rivate "ub Command#Clic$%3ndex .s 3nteger&
? 1 %? B 16& : 3ndex
displa9.Text 1 ?
End "ub
!rivate "ub Command1#Clic$%3ndex .s 3nteger&
@ 1 ?
? 1 6
op 1 3ndex
3f %op 1 7& Ten
f 1 @ 5 16
A 1 f
displa9.Text 1 A
? 1 A
End 3f
End "ub
!rivate "ub Command2#Clic$%&
"elect Case op
Case 6, A 1 @ : ?
Case 1, A 1 @ ; ?
Case 2, A 1 @ B ?
Case =, A 1 @ 5 ?
Case >, A 1 9(odx
Case 7, f 1 @ 5 16
A 1 f
End "elect
displa9.Text 1 A
? 1 A
op 1 6
End "ub
!rivate "ub Command=#Clic$%&
? 1 6
@ 1 6
A 1 6
f 1 6
op 1 6
displa9.Text 1 A
End "ub
!rivate "ub 0orm#Load%&
? 1 6
@ 1 6
A 1 6
op 1 111
f 1 6
displa9.Text 1 ))
End "ub
C. Create an application using /ifferent Grid Controls
D. Generate one example witout using /ata Control
/im db .s /atabase
/im rs .s *ecordset
/im rs1 .s *ecordset
/im sEl .s "tring
!rivate "ub Cmd#/elete#Clic$%&
"et rs1 1 db.Open*ecordset%)select count%B& from student1 were rollno1) - #
4al%Txt#*Oll+o.Text&&
3f Txt#*Oll+o.Text 1 )) Ten
(sgBox )enter a valid roll number)
Exit "ub
End 3f
3f rs1%6& 1 6 Ten
(sgBox %)tere are no records wit tis roll number)&
Exit "ub
End 3f
db.Execute %)delete from student1 were rollno1) - #
4al%Txt#*Oll+o.Text&&
(sgBox %)record deleted)&
End "ub
!rivate "ub Cmd#Edit#Clic$%&
Clear#Controls
Cmd#Edit.Enabled 1 0alse
End "ub
!rivate "ub cmd#Exit#Clic$%&
'nload (e
End "ub
!rivate "ub Cmd#"ave#Clic$%&
3f Cmd#3nsert.Enabled 1 0alse Ten
sEl 1 ) insert into student1 values%) - #
C3nt%Txt#*Oll+o.Text& - ),F) - #
Txt#+ame.Text - )F,F) - #
Txt#.ddress.Text - )F,) - #
C/bl%Txt#(obile+umber.Text& - )&)
(sgBox sEl
db.Execute %sEl&
(sgBox %)record inserted)&
Cmd#3nsert.Enabled 1 True
End 3f
3f Cmd#Edit.Enabled 1 0alse Ten
sEl 1 )update student1 set name1F) - Txt#+ame.Text - ) F,address1F) - #
Txt#.ddress.Text - )F,mobilenumber1) - #
C/bl%Txt#(obile+umber.Text& - ) were %*oll+O1 ) - #
C3nt%Txt#*Oll+o.Text& - )&)
(sgBox sEl
db.Execute %sEl&
(sgBox %)record updated)&
Cmd#Edit.Enabled 1 True
End 3f
End "ub
!rivate "ub 0orm#Load%&
"et db 1 Open/atabase%)/,GpavanG4bLab(anualG!rg1Gmca1.mdb), True&
"et rs 1 db.Open*ecordset%)student1), dbOpen/9naset&
rs.(ove0irst
F"ow#/ata
End "ub
!rivate "ub Cmd#0irst#Clic$%&
rs.(ove0irst
"ow#/ata
End "ub
!rivate "ub Cmd#Last#Clic$%&
rs.(oveLast
"ow#/ata
End "ub
!rivate "ub Cmd#+ext#Clic$%&
rs.(ove+ext
"ow#/ata
End "ub
!rivate "ub Cmd#!revious#Clic$%&
rs.(ove!revious
"ow#/ata
End "ub
!rivate "ub Cmd#3nsert#Clic$%&
Clear#Controls
Cmd#3nsert.Enabled 1 0alse
Txt#*Oll+o."et0ocus
End "ub
!rivate "ub "ow#/ata%&
3f rs.EO0 Ten
rs.(oveLast
End 3f
3f rs.BO0 Ten
rs.(ove0irst
End 3f
Txt#*Oll+o.Text 1 rs%6&
Txt#+ame.Text 1 rs%1&
Txt#.ddress.Text 1 rs%2&
Txt#(obile+umber.Text 1 rs%=&
End "ub
!rivate "ub Clear#Controls%&
Txt#*Oll+o.Text 1 ))
Txt#+ame.Text 1 ))
Txt#.ddress.Text 1 ))
Txt#(obile+umber.Text 1 ))
End "ub
H. Create an application using 8oriAantal and 4ertical "croll Bars
/im obI .s ObIect
!rivate "ub c$#Bold#Clic$%&
3f c$#Bold.4alue 1 1 Ten
obI.Bold 1 True
Else
obI.Bold 1 0alse
End 3f
End "ub
!rivate "ub c$#3talic#Clic$%&
3f c$#3talic.4alue 1 1 Ten
obI.3talic 1 True
Else
obI.3talic 1 0alse
End 3f
End "ub
!rivate "ub c$#"tri$e#Clic$%&
3f c$#"tri$e.4alue 1 1 Ten
obI."tri$etroug 1 True
Else
obI."tri$etroug 1 0alse
End 3f
End "ub
!rivate "ub c$#'nderline#Clic$%&
3f c$#'nderline.4alue 1 1 Ten
obI.'nderline 1 True
Else
obI.'nderline 1 0alse
End 3f
End "ub
!rivate "ub 0orm#Load%&
"et obI 1 Txt#"ample.0ont
End "ub
!rivate "ub 8"*#*ed#Cange%&
Txt#"ample.Bac$Color 1 *GB%4al%8"*#*ed&, 4al%8"*#Green&, 4al%8"*#Blue&&
End "ub
!rivate "ub 8"*#Green#Cange%&
Txt#"ample.Bac$Color 1 *GB%4al%8"*#*ed&, 4al%8"*#Green&, 4al%8"*#Blue&&
End "ub
!rivate "ub 8"*#Blue#Cange%&
Txt#"ample.Bac$Color 1 *GB%4al%8"*#*ed&, 4al%8"*#Green&, 4al%8"*#Blue&&
End "ub
!rivate "ub 4"*#*ed#Cange%&
Txt#"ample.Bac$Color 1 *GB%4al%4"*#*ed&, 4al%4"*#Green&, 4al%4"*#Blue&&
End "ub
!rivate "ub 4"*#Green#Cange%&
Txt#"ample.Bac$Color 1 *GB%4al%4"*#*ed&, 4al%4"*#Green&, 4al%4"*#Blue&&
End "ub
!rivate "ub 4"*#Blue#Cange%&
Txt#"ample.Bac$Color 1 *GB%4al%4"*#*ed&, 4al%4"*#Green&, 4al%4"*#Blue&&
End "ub
J. Create an application using (enus
Option Explicit
/im db .s /atabase
/im rs .s *ecordset
/im rs1 .s *ecordset
/im sEl .s "tring
/im insert#flag .s Boolean
/im update#flag .s Boolean
!rivate "ub 0orm#Load%&
"et db 1 Open/atabase%)/,GpavanG4bLab(anualG!rg1Gmca1.mdb), True&
"et rs 1 db.Open*ecordset%)student1), dbOpen/9naset&
rs.(ove0irst
F"ow#/ata
End "ub
!rivate "ub insert#Clic$%3ndex .s 3nteger&
Clear#Controls
insert#flag 1 True
Txt#rollno."et0ocus
End "ub
!rivate "ub delete#Clic$%3ndex .s 3nteger&
"et rs1 1 db.Open*ecordset%)select count%B& from student1 were rollno1) - #
4al%Txt#rollno.Text&&
3f Txt#rollno.Text 1 )) Ten
(sgBox )enter a valid roll number)
Exit "ub
End 3f
3f rs1%6& 1 6 Ten
(sgBox %)tere are no records wit tis roll number)&
Exit "ub
End 3f
db.Execute %)delete from student1 were rollno1) - #
4al%Txt#rollno.Text&&
(sgBox %)record deleted)&
End "ub
!rivate "ub update#Clic$%3ndex .s 3nteger&
Clear#Controls
update#flag 1 True
End "ub
!rivate "ub mnu#save#Clic$%&
3f insert#flag 1 True Ten
sEl 1 ) insert into student1 values%) - #
C3nt%Txt#rollno.Text& - ),F) - #
txt#name.Text - )F,F) - #
txt#address.Text - )F,) - #
C/bl%txt#mobilenumber.Text& - )&)
(sgBox sEl
db.Execute %sEl&
(sgBox %)record inserted)&
insert#flag 1 0alse
End 3f
3f update#flag 1 True Ten
sEl 1 )update student1 set name1F) - txt#name.Text - ) F,address1F) - #
txt#address.Text - )F,mobilenumber1) - #
C/bl%txt#mobilenumber.Text& - ) were %*oll+O1 ) - #
C3nt%Txt#rollno.Text& - )&)
(sgBox sEl
db.Execute %sEl&
(sgBox %)record updated)&
update#flag 1 0alse
End 3f
End "ub
!rivate "ub first#Clic$%3ndex .s 3nteger&
rs.(ove0irst
"ow#/ata
End "ub
!rivate "ub last#Clic$%3ndex .s 3nteger&
rs.(oveLast
"ow#/ata
End "ub
!rivate "ub next#Clic$%3ndex .s 3nteger&
rs.(ove+ext
"ow#/ata
End "ub
!rivate "ub previous#Clic$%3ndex .s 3nteger&
rs.(ove!revious
"ow#/ata
End "ub
!rivate "ub end#Clic$%&
'nload (e
End "ub
!rivate "ub "ow#/ata%&
3f rs.EO0 Ten
rs.(oveLast
End 3f
3f rs.BO0 Ten
rs.(ove0irst
End 3f
Txt#rollno.Text 1 rs%6&
txt#name.Text 1 rs%1&
txt#address.Text 1 rs%2&
txt#mobilenumber.Text 1 rs%=&
End "ub
!rivate "ub Clear#Controls%&
Txt#rollno.Text 1 ))
txt#name.Text 1 ))
txt#address.Text 1 ))
txt#mobilenumber.Text 1 ))
End "ub
16. Create an application 'sing (/3 form wit Toolbar control
!rivate "ub Toolbar1#ButtonClic$%B94al Button .s ("ComctlLib.Button&
"elect Case Button.Ke9
Case )!rogram1)
Load frm#!rg1
frm#!rg1."ow
frm#!rg1."et0ocus
Case )!rogram2)
Load frm#!rg2
frm#!rg2."ow
frm#!rg2."et0ocus
Case )Combo)
Load frm#!rg=
frm#!rg=."ow
frm#!rg=."et0ocus
Case )Grid)
Load frm#!rgC
frm#!rgC."ow
frm#!rgC."et0ocus
Case )8oriAantal)
Ffrm#(/30orm..rrange %vbfile8oriAantal&
frm#(/30orm..rrange %1&
Case )4ertical)
Ffrm#(/30orm..rrange %vbfilevertical&
frm#(/30orm..rrange %2&
Case )Cascade)
Ffrm#(/30orm..rrange %vbfilecascade&
frm#(/30orm..rrange %6&
End "elect
End "ub
11. Create .n .pplication 'sing /irListbox, /riveListbox , 0ile Listbox controls
!rivate "ub /ir1#Cange%&
0ile1.!at 1 /ir1.!at
End "ub
!rivate "ub /rive1#Cange%&
/ir1.!at 1 /rive1./rive
End "ub
!rivate "ub cmd#List.ll/rives#Clic$%&
F "can te contents of te /riveListBox control
List1.Clear
List1..dd3tem )L3"T O0 /*34E")
0or i 1 6 To /rive1.ListCount ; 1
List1..dd3tem /rive1.List%i&
+ext
End "ub
!rivate "ub cmd#List.ll0iles#Clic$%&
F "can te contents of te 0ileListBox control
List1.Clear
List1..dd3tem )L3"T O0 03LE")
0or i 1 6 To 0ile1.ListCount ; 1
List1..dd3tem 0ile1.List%i&
+ext
End "ub
!rivate "ub cmd#List.ll"ub0olders#Clic$%&
F "can te contents of te /irListBox control
List1.Clear
List1..dd3tem )L3"T O0 "'B0OL/E*")
0or i 1 6 To /ir1.ListCount ; 1
List1..dd3tem /ir1.List%i&
+ext
End "ub
!rivate "ub cmd#List.ll!arent0olders#Clic$%&
List1.Clear
List1..dd3tem )L3"T O0 !.*E+T 0OL/E*")
p/ept 1 ;1
<ile /ir1.List%p/ept& LM ))
List1..dd3tem /ir1.List%p/ept&
p/ept 1 p/ept ; 1
<end
List1..dd3tem )Te current folder is nested ) - #
;p/ept : 1 - ) folders deep)
End "ub
12. Create an application 'sing !opup (enus
!rivate "ub mnu#frm#!rogram1#Clic$%&
(sgBox )mnu#frm#!rg1)
Load frm#!rg1
frm#!rg1."ow
End "ub
!rivate "ub mnu#frm#!rogram2#Clic$%&
(sgBox )mnu#frm#prg2)
Load frm#!rg2
frm#!rg2."ow
End "ub
!rivate "ub mnu#ComboandList#Clic$%&
(sgBox )mnu#ComboandList)
Load frm#!rg=
frm#!rg=."ow
End "ub
!rivate "ub mnu#GridControls#Clic$%&
(sgBox )mnu#frm#GridControls)
Load frm#!rgC
frm#!rgC."ow
End "ub
1=. Create an application 'sing "ape and Timer controls
!rivate "ub Timer1#Timer%&
"ape1.(ove "ape1.Left : "cale<idt B %*nd ; 6.7& 5 76, "ape1.Top : "cale8eigt
B %*nd ; 6.7& 5 76
"ape2.(ove "ape2.Left : "cale<idt B %*nd ; 6.7& 5 76, "ape2.Top : "cale8eigt
B %*nd ; 6.7& 5 76
"ape=.(ove "ape=.Left : "cale<idt B %*nd ; 6.7& 5 76, "ape=.Top : "cale8eigt
B %*nd ; 6.7& 5 76
"ape>.(ove "ape>.Left : "cale<idt B %*nd ; 6.7& 5 76, "ape>.Top : "cale8eigt
B %*nd ; 6.7& 5 76
End "ub

You might also like

pFad - Phonifier reborn

Pfad - The Proxy pFad of © 2024 Garber Painting. All rights reserved.

Note: This service is not intended for secure transactions such as banking, social media, email, or purchasing. Use at your own risk. We assume no liability whatsoever for broken pages.


Alternative Proxies:

Alternative Proxy

pFad Proxy

pFad v3 Proxy

pFad v4 Proxy