This document contains code for multiple programs in Visual Basic:
1. A program that performs arithmetic operations using command buttons and global variables.
2. A program that takes input for principal, rate, time and calculates simple and compound interest.
3. A program that takes a value for x as input and prints x's multiplication table.
4. An interface like a mark sheet that takes marks in five subjects as input, calculates total marks and percentage, and provides a grade.
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 ratings0% found this document useful (0 votes)
60 views
Question (1) :-Answer
This document contains code for multiple programs in Visual Basic:
1. A program that performs arithmetic operations using command buttons and global variables.
2. A program that takes input for principal, rate, time and calculates simple and compound interest.
3. A program that takes a value for x as input and prints x's multiplication table.
4. An interface like a mark sheet that takes marks in five subjects as input, calculates total marks and percentage, and provides a grade.
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/ 72
Question (1):- WAP to perform arithmetic operation uses command
buttons. (Declare variables globall).
Ans!er:- "orm #aout $hanging Properties and Adding $ontrols Object Property Setting Form Caption Name Border style Arithmetic Operation Form01 3-Fied !ialog Command B"tton Caption Name # Pl"s Command B"tton Caption Name - $in"s Command B"tton Caption Name % $"ltiply Command B"tton Caption Name & !i'ision Command B"tton Caption Name (eset cmd(eset Command B"tton Caption Name )it cmd)it *abel Caption Name First N"mber *abel1 *abel Caption Name Second N"mber *abel+ *abel Caption Name (es"lt *abel3 ,et Bo Name ,et ,et1 ,et Bo Name ,et ,et+ ,et Bo Name ,et ,et3 1 -+
$oding "or %he Program Option Explicit Dim n1#, n2#, r# Private Sub cmdExit_Click( End End Sub Private Sub cmd!e"et_Click( #ext1 $ %% #ext2 $ %% #ext& $ %% #ext1'SetFocu" End Sub Private Sub Divi"ion_Click( n1 $ (al(#ext1'#ext n2 $ (al(#ext2'#ext r $ n1 ) n2 #ext&'#ext $ r End Sub Private Sub *inu"_Click( n1 $ (al(#ext1'#ext n2 $ (al(#ext2'#ext r $ n1 + n2 #ext&'#ext $ r End Sub Private Sub *ultipl,_Click( n1 $ (al(#ext1'#ext n2 $ (al(#ext2'#ext r $ n1 - n2 #ext&'#ext $ r End Sub Private Sub Plu"_Click( n1 $ (al(#ext1'#ext n2 $ (al(#ext2'#ext r $ n1 . n2 #ext&'#ext $ r End Sub + -+
Private Sub #ext1_/e,Pre""(/e,0"cii 0" 1nte2er 13 4ot (/e,0"cii 5$ 67 0nd /e,0"cii 8$ 9: Or /e,0"cii $ 7 Or /e,0"cii $ 6; #<en /e,0"cii $ = End 13 End Sub Private Sub #ext2_/e,Pre""(/e,0"cii 0" 1nte2er 13 4ot (/e,0"cii 5$ 67 0nd /e,0"cii 8$ 9: Or /e,0"cii $ 7 Or /e,0"cii $ 6; #<en /e,0"cii $ = End 13 End Sub Private Sub #ext&_/e,Pre""(/e,0"cii 0" 1nte2er 13 4ot (/e,0"cii 5$ 67 0nd /e,0"cii 8$ 9: Or /e,0"cii $ 7 Or /e,0"cii $ 6; #<en /e,0"cii $ = End 13 End Sub 3 -+
Question (&):-WAP to ta'e input of principal( rate ) time and calculate simple interest ) compound interest. Ans!er:- "orm #aout $hanging Properties and Adding $ontrols Object Property Setting Form Caption Name Border style Calc"late .nterests Form0+ 3-Fied !ialog Command B"tton Caption Name Calc"late interests Calc"late Command B"tton Caption Name (eset cmd(eset Command B"tton Caption Name )it cmd)it *abel Caption Name Principal *abel1 *abel Caption Name (ate *abel+ *abel Caption Name ,ime/in year0 *abel3 *abel Caption Name Simple .nterest *abel1 *abel Caption Name Compo"nd .nterests *abel2 ,et Bo Name ,et ,et1 ,et Bo Name ,et ,et+ ,et Bo Name ,et ,et3 ,et Bo Name ,et ,et1 ,et Bo Name ,et ,et2 $oding "or %he Program 1 -+
Option Explicit Private Sub Calculate_Click( Dim p#, r#, t#, "i#, ci# p $ (al(#ext1 r $ (al(#ext2 t $ (al(#ext& "i $ (p - r - t ) 1== #ext6 $ "i ci $ (p - (1 . r ) 1== > t + p #ext9 $ ci Calculate'Enabled $ Fal"e End Sub Private Sub cmdExit_Click( End End Sub Private Sub cmd!e"et_Click( #ext1 $ %% #ext2 $ %% #ext& $ %% #ext6 $ %% #ext9 $ %% #ext1'SetFocu" Calculate'Enabled $ #rue End Sub Private Sub #ext1_/e,Pre""(/e,0"cii 0" 1nte2er 13 4ot (/e,0"cii 5$ 67 0nd /e,0"cii 8$ 9: Or /e,0"cii $ 7 Or /e,0"cii $ 6; #<en /e,0"cii $ = End 13 End Sub Private Sub #ext2_/e,Pre""(/e,0"cii 0" 1nte2er 13 4ot (/e,0"cii 5$ 67 0nd /e,0"cii 8$ 9: Or /e,0"cii $ 7 Or /e,0"cii $ 6; #<en /e,0"cii $ = End 13 End Sub Private Sub #ext&_/e,Pre""(/e,0"cii 0" 1nte2er 13 4ot (/e,0"cii 5$ 67 0nd /e,0"cii 8$ 9: Or /e,0"cii $ 7 Or /e,0"cii $ 6; #<en /e,0"cii $ = End 13 End Sub 2 -+
Question (*):- Write a program to take input of x and print table of x in the following format. X * 1 = X X * 2 = 2X ----------- ----------- X * 10 = 10*X Ans!er:- "orm #aout $hanging Properties and Adding $ontrols Object Property Setting Form Caption Name Border style Print table Form03 3-Fied !ialog Command B"tton Caption Name Print table cmdPrint Command B"tton Caption Name (eset cmd(eset Command B"tton Caption Name )it cmd)it *abel Caption Name )nter 'al"e o3 *abel1 ,et Bo Name ,et ,et1 4 -+
$oding "or %he Program Option Explicit Private Sub cmdExit_Click( End End Sub Private Sub cmdPrint_Click( Dim ?@, i@, t@ ? $ (al(#ext1 Print % #able o3 %A ? Print A For i $ 1 #o 1= Step 1 t $ ? - i Print ?A %- %A iA %$%A t 4ext i cmdPrint'Enabled $ Fal"e End Sub Private Sub cmd!e"et_Click( #ext1 $ %% *e'cl" #ext1'SetFocu" cmdPrint'Enabled $ #rue End Sub Private Sub #ext1_/e,Pre""(/e,0"cii 0" 1nte2er 13 4ot (/e,0"cii 5$ 67 0nd /e,0"cii 8$ 9: Or /e,0"cii $ 7 #<en /e,0"cii $ = End 13 End Sub - -+
Question (+):- Design an interface( !hich !ill appear li'e mar' sheet. ,t !ill ta'e input of mar's in five sub-ects and calculate total mar's and percentage then provide grade according to follo!ing criteria. (.sing nested if) ( .se tab inde/ propert to move focus ). 13 @ #<en Brade 5 $ C= 0. 5 $ :9 D 8 C= 0 5 $ ;= D 8 :9 E 5 $ 69 D 8 ;= C Ot<erFi"e F Ans!er:- "orm #aout 5 -+
$hanging Properties and Adding $ontrols Object Property Setting Form Caption Name Border style $ar6 sheet Form01 3-Fied !ialog Command B"tton Caption Name ,otal mar6s cmd,otal Command B"tton Caption Name Percentage cmdPercentage Command B"tton Caption Name 7rade cmd7rade Command B"tton Caption Name (eset cmd(eset Command B"tton Caption Name )it cmd)it *abel Caption Name St"dent8s Name *abel1 *abel Caption Name (oll No9 *abel+ *abel Caption Name $athematics *abel3 *abel Caption Name Chemistry *abel1 *abel Caption Name )nglish *abel2 *abel Caption Name :indi *abel4 *abel Caption Name ,otal mar6s *abel- *abel Caption Name Percentage *abel5 *abel Caption Name 7rade *abel; ,et Bo Name ,et ,et1 ,et Bo Name ,et ,et+ ,et Bo Name ,et ,et3 ,et Bo Name ,et ,et1 ,et Bo Name ,et ,et2 ,et Bo Name ,et ,et4 ,et Bo Name ,et ,et- ,et Bo Name ,et ,et5 ,et Bo Name ,et ,et; ; -+
$oding "or %he Program Option Explicit Dim m 0" Double Dim c 0" Double Dim p 0" Double Dim e 0" Double Dim < 0" Double Dim t 0" Double Dim per 0" Double Private Sub cmdExit_Click( End End Sub Private Sub cmdBrade_Click( On Error Bo#o x,G 13 per 5$ C= #<en #ext1='#ext $ %0.% El"e 13 per 5$ :9 0nd per 8 C= #<en #ext1='#ext $ %0% El"e 13 per 5$ ;= 0nd per 8 :9 #<en #ext1='#ext $ %E% El"e 13 per 5$ 69 0nd per 8 ;= #<en #ext1='#ext $ %c% El"e #ext1='#ext $ %Failed% End 13 End 13 End 13 End 13 Exit Sub x,GH *"2Eox %Error#% D Err'4umber D vbCrI3 D Err'De"cription End Sub Private Sub cmdPercenta2e_Click( On Error Bo#o x,G per $ t ) 9 #extC'#ext $ per x,GH *"2Eox %Error#% D Err'4umber D vbCrI3 D Err'De"cription End Sub 10 -+
Private Sub cmd!e"et_Click( #ext1'#ext $ %% #ext2'#ext $ %% #ext&'#ext $ %% #ext6'#ext $ %% #ext9'#ext $ %% #ext;'#ext $ %% #ext:'#ext $ %% #ext7'#ext $ %% #extC'#ext $ %% #ext1='#ext $ %% #ext1'SetFocu" End Sub Private Sub cmd#otal_Click( On Error Bo#o x,G m $ #ext&'#ext c $ #ext6'#ext p $ #ext9'#ext e $ #ext;'#ext < $ #ext:'#ext t $ m . c . p . e . < #ext7'#ext $ t Exit Sub x,GH *"2Eox %Error#% D Err'4umber D Err'De"cription End Sub Private Sub #ext1_/e,Pre""(/e,0"cii 0" 1nte2er 13 4ot ((/e,0"cii 5$ ;9 0nd /e,0"cii 8$ C= Or (/e,0"cii 5$ C: 0nd /e,0"cii 8$ 122 Or /e,0"cii $ 7 Or /e,0"cii $ 6; Or /e,0"cii $ &2 #<en /e,0"cii $ = End 13 End Sub Private Sub #extC_/e,Pre""(/e,0"cii 0" 1nte2er 13 4ot (/e,0"cii 5$ 67 0nd /e,0"cii 8$ 9: Or /e,0"cii $ 7 Or /e,0"cii $ 6; #<en /e,0"cii $ = End 13 End Sub Private Sub #ext2_/e,Pre""(/e,0"cii 0" 1nte2er 13 4ot (/e,0"cii 5$ 67 0nd /e,0"cii 8$ 9: Or /e,0"cii $ 7 #<en /e,0"cii $ = End 13 End Sub 11 -+
Private Sub #ext&_/e,Pre""(/e,0"cii 0" 1nte2er 13 4ot (/e,0"cii 5$ 67 0nd /e,0"cii 8$ 9: Or /e,0"cii $ 7 Or /e,0"cii $ 6; #<en /e,0"cii $ = End 13 End Sub Private Sub #ext6_/e,Pre""(/e,0"cii 0" 1nte2er 13 4ot (/e,0"cii 5$ 67 0nd /e,0"cii 8$ 9: Or /e,0"cii $ 7 Or /e,0"cii $ 6; #<en /e,0"cii $ = End 13 End Sub Private Sub #ext9_/e,Pre""(/e,0"cii 0" 1nte2er 13 4ot (/e,0"cii 5$ 67 0nd /e,0"cii 8$ 9: Or /e,0"cii $ 7 Or /e,0"cii $ 6; #<en /e,0"cii $ = End 13 End Sub Private Sub #ext;_/e,Pre""(/e,0"cii 0" 1nte2er 13 4ot (/e,0"cii 5$ 67 0nd /e,0"cii 8$ 9: Or /e,0"cii $ 7 Or /e,0"cii $ 6; #<en /e,0"cii $ = End 13 End Sub Private Sub #ext:_/e,Pre""(/e,0"cii 0" 1nte2er 13 4ot (/e,0"cii 5$ 67 0nd /e,0"cii 8$ 9: Or /e,0"cii $ 7 Or /e,0"cii $ 6; #<en /e,0"cii $ = End 13 End Sub Private Sub #ext7_/e,Pre""(/e,0"cii 0" 1nte2er 13 4ot (/e,0"cii 5$ 67 0nd /e,0"cii 8$ 9: Or /e,0"cii $ 7 Or /e,0"cii $ 6; #<en /e,0"cii $ = End 13 End Sub 1+ -+
Question (0):- WAP to create a simple calculator (.sing control arra) Ans!er:- "orm #aout $hanging Properties and Adding $ontrols Object Property Setting Form Caption Name Border style Simple Calc"lator Form02 3-Fied !ialog Command B"tton Array Caption Name 0<1<+<3<1<2<4<-<5<; Cmddigit Command B"tton Caption Name #<-<%<& cmdOperator Command B"tton Caption Name 9 cmd!ot Command B"tton Caption Name = cmd)>"al Command B"tton Caption Name Cls cmdClear Command B"tton Caption Name On&O33 cmdOnO33 ,et Bo Name ,et ,et1 13 -+
$oding "or %he Program Option Explicit Dim a 0" Double, 3 0" 1nte2er, i 0" 1nte2er Dim b 0" Double Dim re" 0" Double Dim op 0" 1nte2er Private Sub cmdClear_Click( #ext1 $ = cmdDot'Enabled $ #rue End Sub Private Sub cmdDot_Click( #ext1 $ #ext1 D %'% cmdDot'Enabled $ Fal"e End Sub Private Sub cmdEJual_Click( b $ (al(#ext1 13 op $ = #<en re" $ a . b El"e13 op $ 1 #<en re" $ a + b El"e13 op $ 2 #<en re" $ a - b El"e13 op $ & #<en re" $ a ) b El"e re" $ = End 13 #ext1 $ "tr(re" cmdEJual'Enabled $ Fal"e End Sub Private Sub cmdOnO33_Click( 13 3 $ 1 #<en 3 $ = For i $ = #o C cmddi2it(i'Enabled $ #rue 4ext i For i $ = #o & cmdOperator(i'Enabled $ #rue 4ext i cmdClear'Enabled $ #rue cmdDot'Enabled $ #rue cmdEJual'Enabled $ #rue #ext1'#ext $ = El"e 3 $ 1 11 -+
For i $ = #o C cmddi2it(i'Enabled $ Fal"e 4ext i For i $ = #o & cmdOperator(i'Enabled $ Fal"e 4ext i cmdClear'Enabled $ Fal"e cmdEJual'Enabled $ Fal"e cmdDot'Enabled $ Fal"e #ext1'#ext $ %% End 13 End Sub Private Sub cmddi2it_Click(1ndex 0" 1nte2er 13 #ext1 $ = #<en #ext1 $ 1ndex El"e #ext1 $ #ext1 D 1ndex End 13 cmdEJual'Enabled $ #rue End Sub Private Sub cmdOperator_Click(1ndex 0" 1nte2er a $ (al(#ext1 #ext1 $ = op $ 1ndex cmdDot'Enabled $ #rue cmdEJual'Enabled $ #rue End Sub Private Sub Form_Ioad( 3 $ 1 For i $ = #o C cmddi2it(i'Enabled $ Fal"e 4ext i For i $ = #o & cmdOperator(i'Enabled $ Fal"e 4ext i cmdClear'Enabled $ Fal"e cmdDot'Enabled $ Fal"e cmdEJual'Enabled $ Fal"e End Sub 12 -+
Question (1):- Write a program to chec' !hether an centered no. is prime or not. (.sing for loop ) 2/it for) Ans!er:- "orm #aout $hanging Properties and Adding $ontrols Object Property Setting Form Caption Name Border style Chec6 entered no9is prime or not Form04 3-Fied !ialog Command B"tton Caption Name )nter No9 cmd)nterNo Command B"tton Caption Name Chec6 Prime or not cmdChec6 Command B"tton Caption Name )it cmd)it Command B"tton Caption Name Cls cmdClear $oding "or %he Program Option Explicit Dim n@, i@ Private Sub cmdC<eck_Click( For i $ 2 #o n + 1 Step 1 13 n *od i $ = #<en Exit For End 13 4ext i 13 (n $ i #<en *"2Eox (% Prime 4umber% El"e *"2Eox (%4ot Prime 4umber% End 13 cmdC<eck'Enabled $ Fal"e End Sub 14 -+
Private Sub cmdEnter4o_Click( On Error Bo#o error<andler cmdC<eck'Enabled $ #rue n $ 1nputEox(%Enter 4umber t<at ,ou Fant to c<eck Prime on not% Exit Sub error<andlerH *"2Eox %Plea"e enter an, number'% End Sub Private Sub cmdExit_Click( End End Sub Private Sub Form_Ioad( cmdC<eck'Enabled $ Fal"e End Sub 1- -+
Question (3):- Write a program !hich !ill count all vo!els( consonants( digits( special characters and blan' spaces in a sentences (.sing select case) Ans!er:- "orm #aout $hanging Properties and Adding $ontrols Object Property Setting Form Caption Name Border style A Program ?hich ?ill co"nt all 'o?els< consonants< digits< special character and blan6 spaces in a sentences9 Form0- 3-Fied !ialog Command B"tton Caption Name .np"t sentence cmd.np"t Command B"tton Caption Name Co"nt cmdCo"nt Command B"tton Caption Name )it cmd)it Command B"tton Caption Name Clear Form cmdClear 15 -+
$oding "or %he Program Option Explicit Option Ea"e 1 Dim " 0" Strin2 Private Sub cmd1nput_Click( " $ 1nputEox(%Enter an, "entence%, %1nput% cmdCount'Enabled $ #rue End Sub Private Sub cmdCount_Click( Dim v@, c@, d@, "c@, b"@, i@, l@ Dim "1 0" Strin2 l $ Ien(" Print %Entered "entenceH% Print " For i $ 1 #o l "1 $ *id(", i, 1 Select Ca"e "1 Ca"e %a%, %e%, %i%, %o%, %u%, %0%, %E%, %1%, %O%, %K% v $ v . 1 Ca"e % % b" $ b" . 1 Ca"e El"e Select Ca"e 0"c("1 Ca"e 67 #o 9: d $ d . 1 Ca"e ;9 #o C= c $ c . 1 Ca"e C: #o 122 c $ c . 1 Ca"e El"e "c $ "c . 1 End Select End Select 4ext i Print %(oFel" $ % D v Print %Con"onent" $ % D c Print %Di2it" $ % D d Print %Elank Space" $ % D b" Print %Special C<aracter $ % D "c End Sub Private Sub cmdClear_Click( *e'cl" cmdCount'Enabled $ Fal"e End Sub 1; -+
Private Sub cmdExit_Click( End End Sub Private Sub Form_Ioad( cmdCount'Enabled $ Fal"e End Sub +0 -+
Question (4):- WAP to illustrate all functionalities of list bo/ and combo bo/' Ans!er:- "orm #aout $hanging Properties and Adding $ontrols Object Property Setting Form Caption Name Border style A Program to ill"strate all 3"nctionalities o3 list bo and combo bo9 Form05 3-Fied !ialog Command B"tton Caption Name Add .tem cmdAdd.tem1 Command B"tton Caption Name (emo'e .tem cmd(emo'e.tem1 Command B"tton Caption Name Clear Combo cmdClearCombo Command B"tton Caption Name Add .tem cmdAdd.tem+ Command B"tton Caption Name (emo'e .tem cmd(emo'e.tem1 Command B"tton Caption Name Clear *ist cmdClearlist Frame Caption Name Combo bo Frame1 Frame Caption Name *ist bo Frame+ Combo Bo Name Combo1 +1 -+
*ist ,et B9C9A9-.< B9C9A9-..< B9C9A9-...< B9Sc9-.< B9Sc9-..< B9Sc9-... B9C9A9-. *ist Bo Name *ist *ist1 B9Com9-.<B9Com9-..< B9Com9- ...< B9A9-.< B9A9-..< B9A9-... ,et Bo Name ,et ,et1 $oding "or %he Program Option Explicit Private Sub cmd0dd1tem1_Click( Combo1'0dd1tem (Combo1 End Sub Private Sub cmd!emove1tem1_Click( On Error !e"ume 4ext Combo1'!emove1tem Combo1'Ii"t1ndex End Sub Private Sub cmdClearCombo_Click( Combo1'Clear End Sub Private Sub cmd0dd1tem2_Click( Ii"t1'0dd1tem (#ext1'#ext #ext1 $ %% End Sub Private Sub cmd!emove1tem2_Click( On Error !e"ume 4ext Ii"t1'!emove1tem Ii"t1'Ii"t1ndex End Sub Private Sub cmdClearIi"t_Click( Ii"t1'Clear End Sub Private Sub cmdExit_Click( End End Sub ++ -+
Question (5):- WAP using chec' bo/es for follo!ing font effects. 6old ,talic .nderline ,ncrease font si7e Decrease font si7e "ont color Ans!er:- "orm #aout $hanging Properties and Adding $ontrols Object Property Setting Form Caption Name Border style A Program to Create e33ects on 3ont "sing chec6 boes9 Form05 3-Fied !ialog Chec6 Bo Caption Name Bold Chec6Blod Chec6 Bo Caption Name .talic Chec6.talic Chec6 Bo Caption Name @nderline Chec6@nderline Chec6 Bo Caption Name 1+ Chec61+ Chec6 Bo Caption Name 11 Chec611 Chec6 Bo Caption Name 15 Chec615 +3 -+
Chec6 Bo Caption Name (ed Chec6(ed Chec6 Bo Caption Name 7reen Chec67reen Chec6 Bo Caption Name Bl"e Chec6Bl"e *abel Caption Name Style *abel1 *abel Caption Name Font SiAe *abel+ *abel Caption Name Font Color *abel3 ,et Bo Name ,et ,et1 (oshan Singh $oding "or %he Program Option Explicit Private Sub C<eckEold_Click( 13 C<eckEold'(alue $ 1 #<en #ext1'FontEold $ #rue El"e #ext1'FontEold $ Fal"e End 13 End Sub Private Sub C<eck1talic_Click( 13 C<eck1talic'(alue $ 1 #<en #ext1'Font1talic $ #rue El"e #ext1'Font1talic $ Fal"e End 13 End Sub Private Sub C<eckKnderline_Click( 13 C<eckKnderline'(alue $ 1 #<en #ext1'FontKnderline $ #rue El"e #ext1'FontKnderline $ Fal"e End 13 End Sub Private Sub C<eck12_Click( 13 C<eck12'(alue $ 1 #<en C<eck16'(alue $ = C<eck17'(alue $ = #ext1'FontSiGe $ 12 El"e #ext1'FontSiGe $ 7 +1 -+
End 13 End Sub Private Sub C<eck16_Click( 13 C<eck16'(alue $ 1 #<en C<eck12'(alue $ = C<eck17'(alue $ = #ext1'FontSiGe $ 16 El"e #ext1'FontSiGe $ 7 End 13 End Sub Private Sub C<eck17_Click( 13 C<eck17'(alue $ 1 #<en C<eck12'(alue $ = C<eck16'(alue $ = #ext1'FontSiGe $ 17 El"e #ext1'FontSiGe $ 7 End 13 End Sub Private Sub C<eck!ed_Click( 13 C<eck!ed'(alue $ 1 #<en C<eckBreen'(alue $ = C<eckElue'(alue $ = #ext1'ForeColor $ vb!ed El"e13 C<eck!ed'(alue $ = 0nd C<eckBreen'(alue $ = 0nd C<eckElue'(alue $ = #<en #ext1'ForeColor $ vb!e"Cur"or End 13 End Sub Private Sub C<eckBreen_Click( 13 C<eckBreen'(alue $ 1 #<en C<eck!ed'(alue $ = C<eckElue'(alue $ = #ext1'ForeColor $ vbBreen El"e13 C<eck!ed'(alue $ = 0nd C<eckBreen'(alue $ = 0nd C<eckElue'(alue $ = #<en #ext1'ForeColor $ vb!e"Cur"or End 13 End Sub Private Sub C<eckElue_Click( 13 C<eckElue'(alue $ 1 #<en +2 -+
C<eck!ed'(alue $ = C<eckBreen'(alue $ = #ext1'ForeColor $ vbElue El"e13 C<eck!ed'(alue $ = 0nd C<eckBreen'(alue $ = 0nd C<eckElue'(alue $ = #<en #ext1'ForeColor $ vb!e"Cur"or End 13 End Sub Private Sub Form_Ioad( C<eck12'(alue $ 1 End Sub +4 -+
Question (18):- WAP for temperature conversion using option button. Ans!er:- "orm #aout $hanging Properties and Adding $ontrols Object Property Setting Form Caption Name Border style ,emperat"re con'ersion9 Form10 3-Fied !ialog Command B"tton Caption Name Con'ert cmdCon'ert Command B"tton Caption Name (eset cmd(eset Command B"tton Caption Name )it cmd)it Option B"tton Caption Name Fahrenheit to Centigrade Option+ Option B"tton Caption Name Centigrade to Fahrenheit Option1 *abel Caption Name ,emperat"re in centigrade *abel1 *abel Caption Name ,emperat"re in Fahrenheit *abel1 ,et Bo Name tet ,et1 ,et Bo Name tet ,et+ +- -+
$oding "or %he Program Option Explicit Private Sub cmdConvert_Click( Dim c 0" Sin2le Dim 3 0" Sin2le c $ (al(#ext1'#ext 3 $ (al(#ext2'#ext 13 Option1 $ #rue #<en 3 $ (C - (c ) 9 . &2 #ext2'#ext $ 3 El"e13 Option2 $ #rue #<en c $ ((3 + &2 ) C - 9 #ext1'#ext $ c End 13 End Sub Private Sub cmd!e"et_Click( #ext1'#ext $ %% #ext2'#ext $ %% Option1 $ Fal"e Option2 $ Fal"e End Sub Private Sub cmdExit_Click( End End Sub Private Sub Form_Ioad( #ext1'Enabled $ Fal"e #ext2'Enabled $ Fal"e End Sub Private Sub Option1_Click( 13 Option1 $ #rue #<en #ext1'#ext $ %% #ext2'#ext $ %% #ext1'Iocked $ Fal"e #ext1'Enabled $ #rue #ext1'SetFocu" #ext2'Enabled $ #rue #ext2'Iocked $ #rue End 13 End Sub +5 -+
Private Sub Option2_Click( 13 Option2 $ #rue #<en #ext1'#ext $ %% #ext2'#ext $ %% #ext2'Iocked $ Fal"e #ext2'Enabled $ #rue #ext2'SetFocu" #ext1'Enabled $ #rue #ext1'Iocked $ #rue End 13 End Sub +; -+
Question (11):- WAP to launch a roc'et using pictures bo/ and timer control. Ans!er:- "orm #aout $hanging Properties and Adding $ontrols Object Property Setting Form Caption Name Border style (oc6et *a"ching Form11 3-Fied !ialog Command B"tton Caption Name (estart cmd(estart Command B"tton Caption Name )it cmd)it Pict"re Bo Name Pict"re Pict"re1 19bmp ,imer Name .nter'al ,imer1 10 30 -+
$oding "or %he Program Option Explicit Private Sub cmdExit_Click( End End Sub Private Sub cmd!e"tart_Click( Picture1'#op $ ;C;= cmd!e"tart'Enabled $ Fal"e End Sub Private Sub Form_Ioad( cmd!e"tart'Enabled $ Fal"e End Sub Private Sub #imer1_#imer( 13 Picture1'#op 5$ = #<en Picture1'#op $ Picture1'#op + 1== End 13 13 Picture1'#op 8$ = #<en cmd!e"tart'Enabled $ #rue End 13 End Sub 31 -+
Question (1&):- WAP to change bac' color of an control (label( te/tbo/) using scroll bo/. Ans!er:- "orm #aout $hanging Properties and Adding $ontrols Object Property Setting Form Caption Name Border style Change bac6 color o3 label and tetbo9 Form1+ 3-Fied !ialog Command B"tton Caption Name (eset cmd(eset Command B"tton Caption Name )it cmd)it :Scrollbar Name :Scroll1 :Scrollbar Name :Scroll+ ,et Bo Name ,et ,et1 ,et Bo *abel Caption Name *abel *abel1 *abel Caption Name $o'e it to change bac6 color o3 *abel *abel+ *abel Caption Name $o'e it to change bac6 color o3 ,et bo *abel3 $oding "or %he Program 3+ -+
Option Explicit Dim i@ Private Sub cmdExit_Click( End End Sub Private Sub cmd!e"et_Click( Iabel1'EackColor $ vbL<ite #ext1'EackColor $ vbL<ite MScroll1'(alue $ = MScroll2'(alue $ = End Sub Private Sub Form_Ioad( Iabel1'Enabled $ Fal"e #ext1'Enabled $ Fal"e End Sub Private Sub MScroll1_Scroll( i $ MScroll1'(alue Iabel1'EackColor $ (i End Sub Private Sub MScroll2_Scroll( i $ MScroll2'(alue #ext1'EackColor $ (i End Sub 33 -+
Question (1*):- WAP to search an element for a one dimension static arra9 Ans!er:- "orm #aout $hanging Properties and Adding $ontrols Object Property Setting Form Caption Name Border style Search an element 3or a one !imension Static array9 Form13 3-Fied !ialog Command B"tton Caption Name .np"t element o3 Array cmd.np"t Command B"tton Caption Name !isplay element o3 Array cmd!isplay Command B"tton Caption Name Searching element o3 Array cmdSearch Command B"tton Caption Name )it cmd)it Command B"tton Caption Name Clear Form cmdClear $oding "or %he Program Option Ea"e 1 Option Explicit Dim a(9 0" 1nte2er Dim i 0" 1nte2er Private Sub cmd1nput_Click( On Error Bo#o error For i $ 1 #o 9 Step 1 a(i $ 1nputEox(%Enter element at % D i D %po"ition%, %1nput% 4ext i 31 -+
Exit Sub errorH *"2Eox %Plea"e enter element" o3 arra,% End Sub Private Sub cmdDi"pla,_Click( For i $ 1 #o 9 Step 1 Print a(iA 4ext i End Sub Private Sub cmdSearc<_Click( On Error Bo#o error1 Dim item 0" 1nte2er item $ 1nputEox(%Enter value o3 element to "earc<%, %liner Searc<% For i $ 1 #o 9 Step 1 13 (item $ a(i #<en *"2Eox (%Element 3ound at % D i D %po"ition% Exit For End 13 4ext i 13 i $ ; #<en *"2Eox %Element not 3ound in arra,% End 13 Exit Sub error1H *"2Eox %Plea"e enter element to "earc<% End Sub Private Sub cmdClear_Click( *e'cl" End Sub Private Sub cmdExut_Click( End End Sub 32 -+
Question (1+):- WAP to sort a dnamic arra of (A) n numbers (6) n strings (,nput arra si7e at run time0 Ans!er:- "orm #aout $hanging Properties and Adding $ontrols Object Property Setting Form Caption Name Border style 119A Program to Sort !ynamic Array No9 and String Form11 +-siAable Command B"tton Caption Name SiAe o3 Array cmdSiAe1 Command B"tton Caption Name .np"t element o3 Array cmd.np"t1 Command B"tton Caption Name !isplay element o3 Array cmd!isplay1 Command B"tton Caption Name SiAe o3 Array cmdSiAe+ Command B"tton Caption .np"t element o3 Array 34 -+
Name cmd.np"t+ Command B"tton Caption Name !isplay element o3 Array cmd!isplay+ Command B"tton Caption Name )it cmd)it Command B"tton Caption Name Clear Form cmdClear Frame Caption Name N"mbers array Frame1 Frame Caption Name String array Frame+ $oding "or %he Program Option Explicit Option Ea"e 1 Dim num( 0" 1nte2er Dim "tr( 0" Strin2 - 1=, t 0" Strin2 - 1= Dim "@, "1@, i@, N@ Private Sub cmdClear_Click( *e'cl" End Sub Private Sub cmdExit_Click( End End Sub Private Sub cmdSiGe1_Click( " $ 1nputEox(%Enter initial "iGe % !eDim num(" 0" 1nte2er End Sub Private Sub cmdSort2_Click( For i $ 1 #o ("1 + 1 Step 1 For N $ i . 1 #o "1 Step 1 13 ("tr(i 5 "tr(N #<en t $ "tr(i "tr(i $ "tr(N "tr(N $ t End 13 4ext N 4ext i End Sub Private Sub cmd1nput1_Click( For i $ 1 #o " Step 1 num(i $ 1nputEox(%enter value o3 element at % D i 4ext i End Sub 3- -+
Private Sub cmdDi"pla,1_Click( Print %4umber"H% For i $ 1 #o " Step 1 Print num(i 4ext i End Sub Private Sub cmd"ort1_Click( For i $ 1 #o (" + 1 Step 1 For N $ i . 1 #o " Step 1 13 (num(i 5 num(N #<en t $ num(i num(i $ num(N num(N $ t End 13 4ext N 4ext i End Sub Private Sub cmdSiGe2_Click( "1 $ 1nputEox(%Enter initial "iGe % !eDim "tr("1 0" Strin2 - 1= End Sub Private Sub cmd1nput2_Click( For i $ 1 #o "1 Step 1 "tr(i $ 1nputEox(%enter value o3 element at % D i 4ext i End Sub Private Sub cmdDi"pla,2_Click( Print #ab(12=A %Strin2"H% For i $ 1 #o "1 Step 1 Print #ab(12=A "tr(i 4ext i End Sub 35 -+
Question (10):- WAP to ta'e input of t!o matrices and perform their addition( subtraction and multiplication using menu editor. Ans!er:- "orm #aout $oding "or %he Program Option Explicit Option Ea"e 1 Dim m1(&, & 0" 1nte2er Dim m2(&, & 0" 1nte2er Dim m&(&, & 0" 1nte2er Dim i@, N@, r2@, c2@, r1@, c1@ Private Sub add_Click( Print %Sum o3 tFo *atrice"% For i $ 1 #o & Step 1 For N $ 1 #o & Step 1 m&(i, N $ m1(i, N . m2(i, N Print m&(i, NA 4ext N Print 3; -+
4ext i End Sub Private Sub cl"_Click( *e'cl" End Sub Private Sub dm1_Click( Print %Fir"t *atrix% For i $ 1 #o & Step 1 For N $ 1 #o & Step 1 Print m1(i, NA 4ext N Print 4ext i End Sub Private Sub dm2_Click( Print %Second *atrix% For i $ 1 #o & Step 1 For N $ 1 #o & Step 1 Print m2(i, NA 4ext N Print 4ext i End Sub Private Sub ele1_Click( On Error Bo#o error For i $ 1 #o & Step 1 For N $ 1 #o & Step 1 m1(i, N $ 1nputEox(%Enter element at% D i D %,% D N D %po"ition%, %Fir"t 1nput% 4ext N 4ext i Exit Sub errorH *"2Eox %Plea"e enter element" o3 arra,% End Sub Private Sub ele2_Click( On Error Bo#o error1 For i $ 1 #o & Step 1 For N $ 1 #o & Step 1 m2(i, N $ 1nputEox(%Enter element at% D i D %,% D N D %po"ition%, %Fir"t 1nput% 4ext N 10 -+
4ext i Exit Sub error1H *"2Eox %Plea"e enter element" o3 arra,% End Sub Private Sub end_Click( Knload *e End Sub Private Sub mul_Click( Dim k 0" 1nte2er For i $ 1 #o & Step 1 For N $ 1 #o & Step 1 For k $ 1 #o & Step 1 m&(i, N $ m&(i, N . m1(i, k - m2(k, N 4ext k 4ext N 4ext i Print %*ultiplication o3 #Fo *atrice"% For i $ 1 #o & Step 1 For N $ 1 #o & Step 1 Print m&(i, NA 4ext N Print 4ext i End Sub Private Sub "ub_Click( Print %Subtraction o3 #Fo matrice"% For i $ 1 #o & Step 1 For N $ 1 #o & Step 1 m&(i, N $ m1(i, N + m2(i, N Print m&(i, NA 4ext N Print 4ext i End Sub 11 -+
Question (18):- WAP to illustrate call b value and call b reference ( to s!ap to values). Ans!er:- "orm #aout $hanging Properties and Adding $ontrols Object Property Setting Form Caption Name Border style .ll"strate Call by 'al"e and call by re3erence /to s?ap to 'al"es0 Form1- 3-Fied !ialog Command B"tton Caption Name S?apping @sing call by 'al"e cmdS?ap'al Command B"tton Caption Name S?apping @sing call by (e3ernce cmds?apre3 Command B"tton Caption Name (eset cmd(eset Command B"tton Caption Name )it cmd)it *abel Caption Name )nter 'al"e o3 BaB *abel1 *abel Caption Name )nter 'al"e o3 BbB *abel+ *abel Caption Name Cal"e o3 a A3ter s?apping *abel3 *abel Caption Name Cal"e o3 b A3ter s?ap *abel1 ,et Bo Name ,et ,et1 ,et Bo Name ,et ,et+ 1+ -+
,et Bo Name ,et ,et3 ,et Bo Name ,et ,et1 $oding "or %he Program Option Explicit Dim a 0" 1nte2er Dim b 0" 1nte2er Dim t 0" 1nte2er Private Sub cmdExit_Click( End End Sub Private Sub cmd!e"et_Click( #ext1'#ext $ %% #ext2'#ext $ %% #ext&'#ext $ %% #ext6'#ext $ %% #ext1'SetFocu" End Sub Private Sub cmd"Fapval_Click( a $ (al(#ext1'#ext b $ (al(#ext2'#ext Call SFapval(a, b #ext&'#ext $ a #ext6'#ext $ b End Sub Private Sub cmd"Fapre3_Click( a $ (al(#ext1'#ext b $ (al(#ext2'#ext Call SFapre3(a, b #ext&'#ext $ a #ext6'#ext $ b End Sub Private Function SFapval(E,(al a 0" 1nte2er, E,(al b 0" 1nte2er t $ a a $ b b $ t End Function Private Function SFapre3(E,!e3 a 0" 1nte2er, E,!e3 b 0" 1nte2er t $ a 13 -+
a $ b b $ t End Function Private Sub Form_Ioad( #ext&'Iocked $ #rue #ext6'Iocked $ #rue End Sub 11 -+
Question (14):- Write a program to calculate factorial of a number using user defined function. Ans!er:- "orm #aout $hanging Properties and Adding $ontrols Object Property Setting Form Caption Name Border style A Program to calc"late 3actorial o3 a n"mber "sing "ser de3inded 3"nction9 Form15 3-Fied !ialog Command B"tton Caption Name Factorial cmdFactorial Command B"tton Caption Name (eset cmd(eset Command B"tton Caption Name )it cmd)it *abel Caption Name )nter the No9 to calc"late 3actorial *abel1 *abel Caption Name Factorial o3 )ntered No9 *abe+ ,et Bo Name ,et ,et1 ,et Bo Name ,et ,et+ 12 -+
$oding "or %he Program Option Explicit Dim 3 0" Ion2 Dim n 0" Ion2 Dim i 0" Ion2 Private Sub cmdExit_Click( End End Sub Private Sub cmdFactorial_Click( cmd!E"et'Enabled $ #rue n $ (al(#ext1 3 $ 3actorial(n #ext2 $ 3 End Sub Private Sub cmd!E"et_Click( #ext1 $ %% #ext2 $ %% #ext1'SetFocu" End Sub Private Function 3actorial(n 0" Ion2 0" Ion2 3 $ 1 For i $ 1 #o n Step 1 3 $ 3 - i 4ext i 3actorial $ 3 End Function Private Sub Form_Ioad( #ext2'Iocked $ #rue cmd!E"et'Enabled $ Fal"e End Sub 14 -+
Question (15):- %a'e input of a !ord and WAP to chec' !hether it is a palindrome or not. (Without using structure fun) . Ans!er:- "orm #aout $hanging Properties and Adding $ontrols Object Property Setting Form Caption Name Border style Chec6 Dhether a ?ord is a palindrome or not9 Form1; 3-Fied !ialog Command B"tton Caption Name Chec6 cmdChec6 Command B"tton Caption Name (eset cmd(eset Command B"tton Caption Name )it cmd)it *abel Caption Name )nter a ?ord *abel1 ,et Bo Name tet ,et1 1- -+
$oding "or %he Program Option Explicit Private Sub cmdc<eck_Click( Dim F1 0" Strin2 Dim F2 0" Strin2 Dim l 0" 1nte2er Dim i 0" 1nte2er F1 $ (#ext1'#ext l $ Ien(F1 13 l 5 = #<en For i $ l #o 1 Step +1 F2 $ F2 D *id(F1, i, 1 4ext i End 13 13 F1 $ F2 #<en *"2Eox %Pallindrome% El"e *"2Eox %4ot Pallindrome% End 13 End Sub Private Sub cmdExit_Click( End End Sub Private Sub cmd!e"et_Click( #ext1'#ext $ %% #ext1'SetFocu" End Sub 15 -+
Question (&8):- WAP to find smallest among given three numbers using user defined procedures. Ans!er:- "orm #aout $hanging Properties and Adding $ontrols Object Property Setting Form Caption Name Border style Find Smallest among gi'en three n"mbers "sing "ser de3ined proced"res9 Form+0 3-Fied !ialog Command B"tton Caption Name Find Smallest no9 cmdFind Command B"tton Caption Name (eset cmd(eset Command B"tton Caption Name )it cmd)it *abel Caption Name )nter 3irst no9 *abel1 *abel Caption Name )nter Second no9 *abel+ *abel Caption Name )nter ,hird no9 *abel3 ,et Bo Name tet ,et1 ,et Bo Name tet ,et+ ,et Bo Name tet ,et3 $oding "or %he Program 1; -+
Option Explicit Private Sub cmdFind_Click( Dim n1 0" 1nte2er Dim n2 0" 1nte2er Dim n& 0" 1nte2er n1 $ (al(#ext1'#ext n2 $ (al(#ext2'#ext n& $ (al(#ext&'#ext Call Find"malle"t(n1, n2, n& End Sub Private Function Find"malle"t(n1 0" 1nte2er, n2 0" 1nte2er, n& 0" 1nte2er 13 (n1 8 n2 #<en 13 (n1 8 n& #<en *"2Eox (%Fir"t no' i" Smalle"t number% El"e *"2Eox (%#<ird no' i" Smalle"t number% End 13 El"e 13 (n2 8 n& #<en *"2Eox (% Second no' i" Smalle"t number% El"e *"2Eox (%#<ird no' i" Smalle"t number% End 13 End 13 End Function Private Sub cmd!e"et_Click( #ext1'#ext $ %% #ext2'#ext $ %% #ext&'#ext $ %% #ext1'SetFocu" End Sub Private Sub cmdExit_Click( End End Sub 20 -+
Question (&1):- WAP to generate( print and find sum of first n elements of fibonacci series using recursion. Ans!er:- "orm #aout $hanging Properties and Adding $ontrols Object Property Setting Form Caption Name Border style Print and 3ind s"m o3 3irst n elements o3 3ibonacci series "sing rec"rsion Form+1 3-Fied !ialog Command B"tton Caption Name Print Series cmdPrintSeries Command B"tton Caption Name !isplay S"m cmd!isplayS"m Command B"tton Caption Name (eset cmd(eset Command B"tton Caption Name )it cmd)it *abel Caption Name )nter no9 o3 ,erms *abel1 *abel Caption Name S"m o3 series*abel+ ,et Bo Name tet ,et1 ,et Bo Name tet ,et+ $oding "or %he Program 21 -+
Option Explicit Private Sub cmdPrintSerie"_Click( Dim a 0" 1nte2er Dim b 0" 1nte2er Dim n 0" 1nte2er n $ (al(#ext1'#ext a $ = b $ 1 Print aA Print bA Call p3ibo(a, b, n End Sub Private Sub cmdDi"pla,Sum_Click( Dim a 0" 1nte2er Dim b 0" 1nte2er Dim n 0" 1nte2er Dim " 0" 1nte2er Dim c 0" 1nte2er n $ (al(#ext1'#ext a $ = b $ 1 " $ "3ibo(a, b, n, c #ext2'#ext $ " End Sub Private Sub cmd!e"et_Click( #ext1'#ext $ %% #ext2'#ext $ %% *e'cl" #ext1'SetFocu" End Sub Private Sub cmdExit_Click( End End Sub Private Function p3ibo(a@, b@, n@ Dim c@ 13 (n 5 = #<en c $ a . b 13 (n 5$ & #<en Print cA End 13 a $ b 2+ -+
b $ c Call p3ibo(a, b, n + 1 End 13 End Function Private Function "3ibo(a@, b@, n@, c@ 0" 1nte2er 13 (n 5 = #<en c $ a . b a $ b b $ c "3ibo $ "3ibo(a, b, n + 1, c El"e "3ibo $ c + 1 End 13 End Function 23 -+
Question (&&):- WAP to perform read !rite operations in a se9uential file. Ans!er:- "orm #aout $hanging Properties and Adding $ontrols Object Property Setting Form Caption Name Border style A Program to per3orm read E ?rite operation in Se>"ential 3ile9 Form++ 3-Fied !ialog Command B"tton Caption Name Find Smallest no9 cmdFind Command B"tton Caption Name (eset cmd(eset Command B"tton Caption Name )it cmd)it *abel Caption Name For ?rite in 3ile *abel1 *abel Caption Name For reading 3rom 3ile *abel+ ,et Bo Name tet ,et1 ,et Bo Name tet ,et+ ,et Bo Name tet ,et3 ,et Bo Name tet ,et1 21 -+
$oding "or %he Program Option Explicit Dim "1 0" Strin2, "2 0" Strin2 Private Sub cmdLrite_Click( Open %!'txt% For Output 0" #1 Lrite #1, #ext1, #ext2 Clo"e #1 *"2Eox %Lrite "ucce""% End Sub Private Sub cmd!ead_Click( Open %!'txt% For 1nput 0" #1 1nput #1, "1, "2 #ext&'#ext $ "1 #ext6'#ext $ "2 Clo"e #1 *"2Eox %File i" "<oFin2% End Sub Private Sub cmdExit_Click( End End Sub 22 -+
Question (&*):- $reate a user defined data tpe having fields name (as string of length &8 btes)( :ollno (as integer)( class (as string of 18 btes). WAP to create a random access file to store above data and perform follo!ing operations in this file. (a) Write ne! record (b) :ead;displa e/isting record (c) Delete an record (d)<earch an record (f) #ist selected records (e) close the file Ans!er:- "orm #aout $hanging Properties and Adding $ontrols Object Property Setting Form Caption Name Border style Drite Ne? (ecord or !isplay Searched (ecord Form+3 3-Fied !ialog Frame Caption Name (ead )isting (ecords Frame1 Frame Caption Name Drite Ne? (ecord or !isplay Searched (ecord Frame Frame Caption Name Controls Frame3 Command B"tton Caption Name Drite cmdDrite Command B"tton Caption Name (ead cmd(ead Command B"tton Caption Name Secrch cmd Secrch 24 -+
Command B"tton Caption Name Close cmd Close *abel Caption Name Name *abel1 *abel Caption Name (oll No9 *abel+ *abel Caption Name Class *abel3 *abel Caption Name Name *abel1 *abel Caption Name (oll N"mber *abel2 *abel Caption Name Class *abel4 ,et Bo Name tet ,et1 ,et Bo Name tet ,et+ ,et Bo Name tet ,et3 *ist Bo Name *ist *ist1 *ist Bo Name *ist *ist+ *ist Bo Name *ist *ist3 2- -+
$oding "or %he Program Option Explicit Option Ea"e 1 Private #,pe "tudent name 0" Strin2 - 2= !ollno 0" 1nte2er cla"" 0" Strin2 - 1= End #,pe Dim "(& 0" "tudent Dim N 0" 1nte2er Dim c 0" 1nte2er Dim i 0" 1nte2er Private Sub Command1_Click( For N $ 1 #o & Bet #1, N, " 13 "(N'!ollno $ (al(#ext2 #<en c $ = *"2Eox %Duplicate !oll no'% Exit Sub El"e c $ c . 1 End 13 4ext N i $ 1nputEox(%Enter 4o'o3 !ecord(betFeen 1 and &% 13 (i 8$ & 0nd c $ & #<en "(i'name $ #ext1'#ext "(i'!ollno $ (al(#ext2'#ext "(i'cla"" $ #ext& Put #1, i, " El"e *"2Eox %Plea"e enter !ecord 4o'1 to &% End 13 End Sub Private Sub Command2_Click( Ii"t1'Clear Ii"t2'Clear Ii"t&'Clear For i $ 1 #o & Step 1 13 i 8$ & #<en Bet #1, i, " Ii"t1'0dd1tem ("(i'name Ii"t2'0dd1tem ("(i'!ollno Ii"t&'0dd1tem ("(i'cla"" End 13 4ext i End Sub 25 -+
Private Sub Command6_Click( Dim r 0" 1nte2er r $ 1nputEox(%Enter !oll 4umber to Searc< !ecord%, %Searc<% For i $ 1 #o & Step 1 Bet #1, i, " 13 ("(i'!ollno $ r #<en Exit For End 13 4ext i 13 (i 8$ & #<en Bet #1, i, " #ext1 $ "(i'name #ext2 $ "(i'!ollno #ext& $ "(i'cla"" El"e *"2Eox %!oll 4umber not 3ound% End 13 End Sub Private Sub Command;_Click( Clo"e #1 End End Sub Private Sub Form_Ioad( Open %"tu'dat% For !andom 0" #1 For i $ 1 #o & Step 1 Bet #1, i, " Ii"t2'0dd1tem "(i'!ollno 4ext i End Sub 2; -+
Question (&+):- WAP to displa records of a table using DA= ) bound control code for buttons to move at first record( ne/t record( previous record( last record in the table. Ans!er:- "orm #aout $hanging Properties and Adding $ontrols Object Property Setting Form Caption Name Border style )mployee !etails Form+1 3-Fied !ialog Command B"tton Caption Name First (ecord cmdFirst Command B"tton Caption Name Net (ecord cmdNet Command B"tton Caption Name Pre'io"s (ecord cmdPre'io"s Command B"tton Caption Name *ast (ecord cmd*ast Command B"tton Caption Name )it cmd)it *abel Caption Name )mployee No9F- *abel1 *abel Caption Name )mployee NameF- *abel+ *abel Caption )mployee AddressF- 40 -+
Name *abel3 *abel Caption Name )mployee SalaryF- *abel1 ,et Bo Name tet ,et1 ,et Bo Name tet ,et+ ,et Bo Name tet ,et3 ,et Bo Name tet ,et1 !ata/!AO0 Caption Name !atabase Name (ecordSo"rse !ata1 !ata1 dG(oshanG*ist o3 Parctical3G+19record9mdb ,he ,able o3 )mployee !etails $oding "or %he Program Option Explicit Private Sub cmdFir"t_Click( Data1'!ecord"et'*oveFir"t End Sub Private Sub cmd4ext_Click( Data1'!ecord"et'*ove4ext 13 Data1'!ecord"et'EOF #<en Data1'!ecord"et'*oveFir"t End 13 End Sub Private Sub cmdPreviou"_Click( Data1'!ecord"et'*ovePreviou" 13 Data1'!ecord"et'EOF #<en Data1'!ecord"et'*oveIa"t End 13 End Sub Private Sub cmdIa"t_Click( Data1'!ecord"et'*oveIa"t End Sub Private Sub cmdExit_Click( End End Sub 41 -+
Question (&0):- $reate a table using visual data manager and !rite a program using :D= ) advanced bound control to add( delete( edit ) navigate records. Ans!er:- "orm #aout 4+ -+
$hanging Properties and Adding $ontrols Object Property Setting Form Caption Name Border style St"dent !etails Form+2 3-Fied !ialog Command B"tton Caption Name First (ecord cmdFirst Command B"tton Caption Name Net (ecord cmdNet Command B"tton Caption Name Pre'io"s (ecord cmdPre'io"s Command B"tton Caption Name *ast (ecord cmd*ast Command B"tton Caption Name Add cmdAdd Command B"tton Caption Name @pdate cmd@pdate Command B"tton Caption Name !elete cmd!elete Command B"tton Caption Name )dit cmd)dit Command B"tton Caption Name )it cmd)it *abel Caption Name Admission No9F- *abel1 *abel Caption Name St"dent NameF- *abel+ *abel Caption Name BirthdayF- *abel3 *abel Caption Name ClassF- *abel1 *abel Caption Name AddressF- *abel2 ,et Bo Name tet ,et1 ,et Bo Name tet ,et+ ,et Bo Name tet ,et3 ,et Bo Name tet ,et1 ,et Bo Name tet ,et2 $S(!C/$icroso3t (emote !ata Control 4900 Name !atabase Name SH* $S(!C1 +2 Select % 3rom St"dent 43 -+
$oding "or %he Program Option Explicit Private Sub cmd0dd_Click( On Error !e"ume 4ext *S!DC1'!e"ult"et'0dd4eF #ext1'SetFocu" cmdKpdate'Enabled $ #rue cmd0dd'Enabled $ Fal"e End Sub Private Sub cmdKpdate_Click( On Error !e"ume 4ext *S!DC1'!e"ult"et'Kpdate cmd0dd'Enabled $ #rue cmdKpdate'Enabled $ Fal"e End Sub Private Sub cmdDelete_Click( *S!DC1'!e"ult"et'Delete *S!DC1'!e"ult"et'*ove4ext 13 *S!DC1'!e"ult"et'EOF #<en *S!DC1'!e"ult"et'*ovePreviou" End 13 End Sub Private Sub cmdEdit_Click( *S!DC1'!e"ult"et'Edit *e'cmdEdit'Enabled $ Fal"e End Sub Private Sub cmdFir"t_Click( cmdEdit'Enabled $ #rue *S!DC1'!e"ult"et'*oveFir"t End Sub Private Sub cmd4ext_Click( cmdEdit'Enabled $ #rue *S!DC1'!e"ult"et'*ove4ext 13 *S!DC1'!e"ult"et'EOF #<en *S!DC1'!e"ult"et'*oveFir"t End 13
End Sub Private Sub cmdPreviou"_Click( cmdEdit'Enabled $ #rue 41 -+
*S!DC1'!e"ult"et'*ovePreviou" 13 *S!DC1'!e"ult"et'EOF #<en *S!DC1'!e"ult"et'*oveIa"t End 13 End Sub Private Sub cmdIa"t_Click( cmdEdit'Enabled $ #rue *S!DC1'!e"ult"et'*oveIa"t End Sub Private Sub cmdExit_Click( End End Sub Private Sub Form_Ioad( cmdKpdate'Enabled $ Fal"e End Sub 42 -+
Question (&1):- WAP to access a database using AD= ) displa a 'e column in the combo bo/ or list bo/ !hen an item is selected in it( its corresponding records is sho!n in ><? fle/ grid. Ans!er:- "orm #aout $hanging Properties and Adding $ontrols Object Property Setting Form Caption Name Border style A Program to Sho? records in $S: 3le grid thro"gh A!C combo bo9 Form+4 3-Fied !ialog Adodc/$icroso3t A!O !ata Control 4900 Name Connection String (ecord So"rce Adodc1 !FG(oshanG*ist o3 PracticalG+49rocord9mdb select % 3rom edetails Adodc/$icroso3t A!O !ata Control 4900 Name Connection String (ecord So"rce Adodc+ !FG(oshanG*ist o3 PracticalG+49rocord9mdb select % 3rom edetails *ist Bo Name !ata Field !ata So"rce *ist1 .! Adodc1 $S: Fle 7rid/$icroso3t :ierarchical Fle 7rid Control 4900 !ata So"rce Adodc+ *abel Caption Name Iey Col"mn o3 .! *abel1 *abel Caption Name $S: Fle 7rid *abel+ 44 -+
$oding "or %he Program Option Explicit Private Sub li"t1_Click( 0dodc2'!ecordSource $ %"elect - 3rom edetail" F<ere id$% D (al(Ii"t1'#ext 0dodc2'!e3re"< End Sub Private Sub Form_Ioad( Do L<ile 4ot 0dodc1'!ecord"et'EOF Ii"t1'0dd1tem 0dodc1'!ecord"et'Field"(= 0dodc1'!ecord"et'*ove4ext Ioop End Sub 4- -+
Question (&3):- K"in2 Data 2nvironment create a pro2ram to di"pla, record" o3 an, table9 Ans!er:- #aout $hanging Properties and Adding $ontrols Object Property Setting !ata)n'ironment Name !ata)n'ironment1 !)Connection Name Connection so"rce Connection1 dFG(oshanG*ist o3 ParcticalG+-9record9$!B deCommand1 Command Name Connection !atabase Object Obiect Name Command1 Connection1 ,able P"blishers !ata(eport Name Caption !ata$ember !ataSo"rce !ata(eport1 !ata(eport+- Command1 !ata)n'ironment1 45 -+
Question (&4):- WAP to generate mar' sheet of students in a class through data report. Ans!er:- #aout $hanging Properties and Adding $ontrols Object Property Setting !ata)n'ironment Name !ata)n'ironment1 !)Connection Name Connection so"rce Connection1 dFG(oshanG*ist o3 ParcticalG+-9record9$!B deCommand1 Command Name Connection !atabase Object Obiect Name Command1 Connection1 ,able P"blishers !ata(eport Name Caption !ata$ember !ataSo"rce !ata(eport+ !ata(eport+- Command1 !ata)n'ironment1 4; -+
Question (&5):- WAP to illustrate various 'e board and mouse events . Ans!er:- "orm #aout $hanging Properties and Adding $ontrols Object Property Setting Form Caption Name Border style A Program to ill"strate 6ey board and mo"se e'ents9 Form+; 3-Fied !ialog Command B"tton Caption Name Command1 Command1 ,et Bo Name tet ,et1 $oding "or %he Program Private Sub Command1_/e,DoFn(/e,Code 0" 1nte2er, S<i3t 0" 1nte2er Command1'EackColor $ vb!ed End Sub Private Sub Command1_/e,Kp(/e,Code 0" 1nte2er, S<i3t 0" 1nte2er Command1'EackColor $ vbBreen End Sub Private Sub Command1_*ou"eDoFn(Eutton 0" 1nte2er, S<i3t 0" 1nte2er, ? 0" Sin2le, O 0" Sin2le Command1'EackColor $ vb*a2enta End Sub Private Sub Command1_*ou"e*ove(Eutton 0" 1nte2er, S<i3t 0" 1nte2er, ? 0" Sin2le, O 0" Sin2le #ext1'EackColor $ vbElue End Sub Private Sub Command1_*ou"eKp(Eutton 0" 1nte2er, S<i3t 0" 1nte2er, ? 0" Sin2le, O 0" Sin2le Command1'EackColor $ vbOelloF End Sub Private Sub #ext1_/e,Pre""(/e,0"cii 0" 1nte2er 13 4ot (/e,0"cii 5$ 6: 0nd /e,0"cii 8$ 9: Or /e,0"cii $ 7 #<en /e,0"cii $ = End 13 End Sub -0 -+
Question (*8):- K"in2 drive( director and file list bo/ (it Fill "<oF onl, 'bmp 3ile"' Iet t<e u"er "elect t<e 'bmp 3ile", F<ic< Fill appear in picture box a" u"er click on an, item in li"t box' Ans!er:- "orm #aout $hanging Properties and Adding $ontrols Object Property Setting Form Caption Name Border style ,he "ser selects the bmp 3iles9 ,his ?ill appear in pict"re bo as "ser clic6 on any item in 3ile list bo9 Form30 3-Fied !ialog File *ist Bo Name File1 !ri'e *ist Bo Name !ri'e1 !ir *ist Bo Name !ir1 Pict"re Bo Name Pict"re1 *abel Caption Name !ri'e Name *abel1 *abel Caption Name !irectory Name *abel+ *abel Caption Name File *abel3 $oding "or %he Program Option Explicit -1 -+
Private Sub Dir1_C<an2e( File1'Pat< $ Dir1'Pat< Iabel2'Caption $ Dir1'Pat< End Sub Private Sub Drive1_C<an2e( On Error Bo#o Errortrap Dir1'Pat< $ Drive1'Drive Exit Sub ErrortrapH *"2Eox %Drive ErrorP%, vbExclamation, %Error% Drive1'Drive $ Dir1'Pat< End Sub Private Sub File1_Click( Picture1'Picture $ IoadPicture(Dir1'Pat< D %)% D File1'File4ame End Sub Private Sub Form_Ioad( File1'Pattern $ %-'bmp% End Sub -+ -+