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

Visual Basic 1&2unit Notes SW 5th Sem.

Uploaded by

YOGESHWAR SINGH
Copyright
© © All Rights Reserved
Available Formats
Download as PDF or read online on Scribd
0% found this document useful (0 votes)
391 views

Visual Basic 1&2unit Notes SW 5th Sem.

Uploaded by

YOGESHWAR SINGH
Copyright
© © All Rights Reserved
Available Formats
Download as PDF or read online on Scribd
You are on page 1/ 80
ist of Selected Questions, = rm assent lt 1 statements in VB. aus.) Esplin Lond and Ut aay sp theses fore PPB oe fay 10 rete Pop iat i Papap sen How nencA 218 Men Epi oa ‘OR spa Popup Mens DURGA 2014 (Q20,b) How do you make a form an MDI (Multi Design Interface) child form? (Q20,) Derive the methodology to create 2 menu using Visual Basi MDUBCA 2018 oR Explain Creating Menus, Sub Menus using example. (Q21(a) Explain Menu desiging in VB. MDUBCA 2017, 2014 oR How are menus designed in VB? Explain using a rogram. (021.0 Describe activate and deactivate events ‘MDU BCA 2017 oR Howto activate and deactivate events? ‘MDU BCA 2016 oR What do you mean by Activate and Deactivate events? Explain, 221.) Explain Form Load event. MU BCA 2014 ho WADHWA's Selected Questions & Answors___17 ere Answers SMS (QU Diseuss the various features of Visual Basic. ‘MDU BCA 2018 Ans. Various feature of Visual Base ae ‘Visual Basie provides the Graphical User Interface (GUD which i easy to use and learn. ‘+ Visual programming languages help user 1 create ‘applications in a short span of tine. ‘+ Visual Basic supports exent-drven programming. In ‘eventedriven programming, an application responds {to user events. + Visual Basi is object oriented. Everything in Visual Basic is an object. fa large application is write, it can be broken into different objects that can be developed separately and thus cam be tested lependently. + Visual Basie provides 21 controls, known as Intrinsic controls, in the toolbox by default when ‘one creates an application. Commonly used controls are command buttons, textboxes, lst Boxes, option buttons, check boxes ete. ‘© "Visual Base can be used to write Internet programs. Visual Basic makes i easy t0 provide access to documents and applications across the Internet oF Intranet from your application. + Visual Basic promotes Rapid Application Development (RAD). Using this, application can be created rapidly. + Visual Basie has ActiveX Support Tt allows to use ‘the functionality provided by other applications. = ee ee ef ‘s ie tas pve dbase eee tos ea cate ab, ronend spplicarions and sealable server-side components for ‘most popular database formats. (Q1.2 Whatis project explorer? MDUBCA 2016, 2014 ‘Ans. The Project Explorer is a window that provides a Iierarchieal view of groups, projects and the source ‘modules associated with he project. “The Project Explorer provides an easy way to navigate between the pans of projets and project groups. A Visual Basie projet fle (vb) is file that contains a listo al the files associated with a projet. ‘When one launches Visual Basic using a group file or ‘jet file (or open an existing group or project from VB), source files hat are associated with the group or project ae displayed in the Projet Explorer window. When one adds or removes files ~ fr example, forms, ‘modules, and so on ~ fr from a project, these changes ane reflected in the Project Explore. (One can use thé buttons on the toolbar atthe top ofthe Project Explorer to view code for any source module, view a module such as form in a designer and contract. ‘orexpand the Explorer tee, Q1.3 Discuss immediate window. MDUBCA 2018 ‘ANS. The Immediate window & the window used to window used to view, debug and editichange values at run time. . Using this, he user can debug and evaluate expression, ecu stemens, peat varisble values, I llows oy WADHWA’s Selected Questions & Answers __19 —_ ee Gestion Answers 9. programmer to enter expressions to be evaluated or ‘executed by the development language during debugging. To display the immediate window, click on, view and then select immediate window. Immediate Window is a great place as it allows modifying. data or testing the function during. is development. User most enter a valid expression inthe immediate window, and VB will exeeute it. However, objects referenced outside the scope of eurret code execution will generate an enor. The Immediate ‘window's sealing and resizing features are so handy. ‘Ths, immediate window isa special window in which ‘one can dreay type Visual Basic comimands, view and change the variables and contol values during 2 programs execution. (Q1.4 What does Procedural Language mean? ‘Ans. A computer programming language that executes a set ‘of commands in an order is called procedural Language. Its written as alist of instructions teling the computes, step-by-step, what to do. In other wort, it contains & systematic onder of statements, functions and commands to complete a computational tsk or program. 20 Meu us Write the benefits of Procedural Langusee- ‘Ans. The benefits of wsing a procedural nguage © 2S follows: ; «+ Procedural language is easier to read and is more maintainable + lis more flexible. ; «+ efacilates the practice of good program design. + Tallows modules tobe reused in the form of code varies. i rocedural 1.6 Compare various features of pt ‘programming and object oriented programming. ‘Ans. Comparison of varius Features of procedural and object- oriented programming sce given bel ine ‘Object Oriented | sh Programming Conia of 1. Mainly sequence sequence of | ofmesages, function cals, too, [2 Rowehars [2 UML diagrams. [3. Modularity [3 Through ]3. Through gba roethods of functions. | objets. 4 Desien 4 Top down, [a Botom up strategy sBraninte[S.rascat,c. [sch aava WADHWA's Selected Questions & Answers ax QL7 How VB supports Integrated Deyelopment Environment? ‘Ans. An Integrated Development Environment (abbreviated as DE) is an application development program that gives programmers the tools required to ereate applications sing a panicular programming language, An IDE is a software application which provides comprehensive facies (computer programmers for software development. Visual Basic supports a builtin-IDE which makes it 2 complete windows based integrated development cavironment, Visual Basic's IDE facilitates a Programming environment integrated into a software application which provides tools such as: source code editor, «compiler ora interpreter, a debugger and tools for managing projects suchas GUI builder Visual Base applications ar created using Visual Baic's builtin IDE (Integrated Development Environment). This built-in IDE allows the user to design applications and add tools to the VB window which the user wants. Thus IDE provides a beter environment forthe programmer to create, run and debug Visual Basi programs effectively and efficiently. IDE allows programmers to erate both simple and complex GUL applications. QL8 What is the sim of Object Programming? Oriented ‘Ans.Objectorested programming is the most. dramatic innovation in software development, I offers @ new and 22 ‘igual Basle jexity of progrars. ae can write clearer, Lie ject-oriented programming One vase -maintaine rams. ass an fac Be Canal es of scored poranming ‘sured proranming mods ai active he folowing | To simplify the design ond inpemenation of compos programs 6 To mate i easier for teams of designers and programmers to work onasngle sofware project ‘To enable a high degree of reusability of designs and of software codes 1s To decrease the cost ofsoftvare maintenance. C9 What are the various applications of object trent programming(OOP)? My comps sto ca be eoped in single A ee io even fees abe in bt ec weranning Vaso pet of OOP a: 00” ie used wo devop the ject ove 000 of aeatwse for implementing the basins ‘enor na tine tome OOP ie weil in newal network and paral ewig ‘+ O0Pis useful in simulation and modeling. /WADHWA's Selected Questions & Answers 23 | + 00P 1 alo ued for inlementing brite | tev exert or sts | © 0P we in offeetmation sytem | + OOP is useful for developing applications based on image processing. Q1.10 What are the characteristics of object oriented programming(OOP)? ‘Ans, Various characteristics of OOP are: ‘© Emphasis is on data rather than on procedure. + Programs are divided ino classes and functions. ‘+ Data is hidden and can not be accessed by external function. ‘+ Nev functions and data items can be added easily. ‘+ Use of inheritance provides reusability of code. ‘+ Follows bottom -up approach in program design. ‘+ Data and functions are ted together in a single unit nown as clas. + Objects communicate with eack other by sending ‘messages inthe form of function, QLALWhat do you mean by Procedural Programming? ‘Ans,Procedures are also known as methods, routines, subroutines oF functions which contain a series of &..... 24 rocedal ‘computational steps to be caried out. So pr of procedural eas. Any given procedure can be called any point during a program's execution. 'A programming language is procedural if it supports procedural programming by having an explicit concept of 8 procedure and syntax to define it It should also support specification of argument types, local variables, recursive procedure calls and use of procedures in separately built program constructs, C, ALGOL are the classe examples ‘of procedural programming languages. MDUBCA 2016 ‘Ans. A constant i @ quantity that doesnot change during the ‘execution of a program. Q1.12 What is constant? ‘A constant is meaningful ame that takes the place of a ‘number or string that does not change. Constants store values tht remain the same thoughout the execution of, an application. One can greatly improve the readability of. the code and make it easier to maintain by using ‘Thus, constants are similar to variables, except that one provides a value forthe constant during declaration and. its value can never change ‘The syntax for declaring a constants: [Public | Global | Private) Cos conitantname [As dataype) = expression __— WADHWA's Selected Questions & Answers __25 oS esters 5 ee Q1.13 What are the basic concepts used in OOPS? ‘Ans. Basic concepts used in OOPS ae: + Objects + Classes ‘© Data abstraction and Encapsulation + Inheritance ‘+ Polymorphism ‘+ Dynamic binding + Message passing QLI4 What are the characteristics of procedure oriented programming language? ‘Ans.Following are the characteristics of procedure oriented programming language: ‘+ Emphasis is on ding things (algoritams). + Data is piven less importance than function. ‘Follows top-down approach in program design. ‘+ Larger programs are divided into smaller programs ‘known as functions. ‘+ Algorithms are designed fist without going into minute details Most of the data is shared at global that con Be ‘accessed from anywhere within the program. + Data moves around the system from function 10 Sanction. isual Basie {QUAS Diseuss te life eyele of 2 form. ‘Ans. The lif cycle ofa form in VB inludes for states as 1. Created (But Not Loaded) [A form is in the crested bat not loaded state when Drograimer clls a userswriten form procedure. This State begins with the Inilize event, In this state, the form exis san object, but has po window and none of its controls exit yet. A form always passes through this state, however it has a bref lay here 2. Loaded (But Not Shown) “Tis state begins with the Load evet-tn this tte, the form has a window although tht window has not yet been shown. A form does not pass” automaticaly through this tat. Code placed in the Form_Load event procedure is executed as soon as the form enters the loaded tat, 3. Shown (Once a form becomes visible, the user is able to interact with i Thereafte, the form may be hidden and shown a5 many times as the user wants before finally being unloaded. 4. Memory and Resources Completely Reclaimed ‘The best way to release all memory space and resources {is to uoload the form and then set all references to Nothing. The reference is most commonly overiooked. ~~ | If at anytime you have referred tothe form by its case name then the hidden global variable has been used. To free the form's memory, this variable must be st 10 Nothing. QUAG Why VB is known as event driven programming language? MDU BCA 2015, oR VB is event driven programming language. ustity it. ‘Ans, Visual Basie Programming allows user to create Various Graphical User Interfaces (GUIs) by pointing and clicking using mouse. Tt eliminates the need for a programmer fo write complex code to generate form and varios objects in VB. Thus a user need not be an expert in programming, Any code is executed when an eveot takes place. The happenings like user clicks are evens Events include mouse click, buton press, menu selection cle. VB application is built up a a series of responses to wer generted events, Thus, Visual Basic is an Event diven programming language. The code remains ite ‘until some event occurs. QUIT What are data types? What are the different datatypes available in VB? nd Ans. Date gpes are used to identify the pe of date operations associated witht “The eiferent datatypes are + Boolean + Bye + Currency + Date + Double epee + Long + Object, + Single + Sting + Vaant : tin tntos in Visa 18 spin the nsf btn a oe eT ot the varius bulla neti available in Visual Basi. fet presale ‘MDU BCA 2018 Ans.Visud Basie bat varius builtin functions. These functions allow manipulation of text, perform ‘ematical operations, formating of data (in standard snd weerdefined styles). The benefit of built-in functions is thatthe user does not need to define them and know ow they work internally. Just call them and they wil acomplish common or complicated sks. ‘Various availabe builtin funeion include; + MspBox() function + InpuBox) fanction + String fonctions Mats furcons + Format() funtion WADHWA's Selected Questions & Answore Example: Swing functions include Len function to ‘etur the length ofa sting. The UCase (and LCase) function can be used to convert ale lowercase). The Math function Math Sqri(n) ean be sed toretum dhe square root ofa number n. Q1.19 How variables are declared in VB? ‘Ans. To declare avaible in VB, Dim statement is used, The syntax ie Dim VarName (As datatype} Where: Dim and As are keywords ‘VarName refers tothe name of variable. Examples: Dim num As Integer Dim stl As String im name As Sting, age As Integer, salary As Double Following rules must be kept in mind while declaring variables + Variable name must begin with a eter. Remaining ‘characters can be lters, digits or underscore. ‘+ Heean not contain a blank space + Keywords can not be used as name of variable, + The maximum size of variable name is 255 characters. + Variable name must be unique within the seme scope (procedure or module in which itis defined. ting loweree 2 (or uppercase) Jeers ina string to uppercase (or a go your meaty the Tae? eae fon whose contents a et meer te =e ‘he changed from within proenam seoctmte im Rolo AEE ; sing, which can bold & data YPE abe is Rel and life time of variables. ‘MDUBCA 2017 lifetime-of 2015 12 Esti soe or Jo you mean by scope and ea) ‘DUCA 201 fe prog in wich le ces A cape of ste, ad tne SE seh emis ine manor is Krona Heine (0122 What do you mean by implicit and expt rail dearation? ‘Ans. Visual Basie allows usage of variables without declaring them. Whenever VB comes across variable that has not been declared, that variable is considered to be implicitly declared and its data type is assumed to be variant. Implicit variable declaration sometimes creates problems. In case, there is any speling mistake while weting variable name, VB does not report any error instead it considers it a a new variable and uses it. To avoid such situations, one can force VB for the explicit declaration ‘of variables. With this VB ensures that all variables must WADHWA’s Selected Qu tons & Answorn 34 te declared using Dim statinem With explicit seclaration ogra rns more eit and actly. QUIS What isa control Now? Ans, Control flow (oF flow of cont) refers to the onder in ich the inividul statements, instructions o¢fnstion calls of program are executed or evaluat QL24 Visual Basie is not an Object Oriented ‘Language’, Justify this statement, ‘Ans.tn onder to term a programming language as objet Oriented Language, it must suppor basic features of Object Orientation such as Data hiding, Inbertance, Dynamic Binding, Polymorphism etc. These all features are missing in VB, so it cannot termed as an Object Oriented Programming, Q125 What do you understand by construct? Selection ‘Ans.The Selection construct means that the execution of statements) depends upon a condita test If this condition evaluated is true then one set of statements is executed otherwise another set of statements is executed ‘This is also called decision construct because raking decision about which set of statements executed. 1.26 What do you understand by eration construct? Ans.The Iteration construct means repetition of a set of SMatements depending upon a condition test. If this coneition is tre (or false depending upon the loop). one 32 visual Baste set of statements are exeeuted again and again. As S000 ae is condition becomes false (or trv), the repetition stops 01.27 What is collection? MDUBCA 2016 ‘Ans. A collection sores related items ) ic for, hate Ina For example, on evry Visi Bas foe, Cone alton. Th election ines all of the conols dawn on the form ~ textos, Command tons ct As on as mor conta he frm, he ontelsclccton kay on expantng Visa Base aso has a pines cllecton which refers (© te pits eae to compu Every Vil Basi projec offers the fos colton. Te mmr of eallecton an be fefened to individually, The members of cleston can perefened into diferent way By using index: Like in an array, one can specify an index number, which is the object's position in the cclletion + By using key:- One can assign each object a string ‘key that uniquely identifies the objects Collections are more powerful than arrays but they run slower. Arrays are approximately twice as fast as collections. Q1.28 What is normal exit? ‘Ans. normal exit takes place when the loop’s test condition falls In this case the contol is transferred 10 the first executable statement following the loop statement An WADHWA’s Solected Quostions & Answers Co etttone Answers 33, Q1.29 Discuss the concept of by statements in Vi, inching and looping Ans. Branching Statements Branching semen ae wt © med pom sien alos fr ioe dechios, Based onsen conten ci om tf ene o het of ele ‘tecued, Visual Basic spports the followtog oes branching statements: «ee of 6) f= Ten Statement (6) f—Then = Ese Statement (© Seles Case Statement Looping Staten nts Wee loi en an option, ef # to operations, is repeated : Somat 48 Jong as some condition is Many tasks consist of tiviat operaiions that must be Fepeated over and over again, and looping structures are Ghinortant part of any programming language. Visual asi suppors the following loop statements: (@) Do~ Loops (6) For Next (©) While- Wend 21.30 What do you understand by Entry Controlled Loop and Exit Control oop? Enley controlled loop evaluates i its tesexpression a the {op of the loop before executing its loop body statements ‘N Visual Basie ———— expression acted ease tesa ste ae HY aoe _ vy conrad Laps ar DOW Ter ae ut Conrad Lop ae Do 1209 Wis ta stint do you undersaid by Se const? ‘Ans. tn his consrct the statements are exceuted sequently ‘This const represents default flow of statements ‘one lin of code is executed afte the he. (0132 How isa For Loop different from While Loop? [Ans. The For Loop executes number of statements fora certain psig of ies. Bu the While Loop executes number of stteens unl the copdtan of while loop i ue Q133 What do you mean by hiding and showing forms? MDU BCA 2018, 2017 ‘Ans, ‘Show’ method The ‘Show’ methods used to display oF show a form. To ety dspay a form to the user, only the Show method is requied. The ladg of the Form objet takes place automaticaly. The Show statement causes the form to spear. Syntax: FormName Show (mode) a oe . | Whece FormName: Fors name. (required) ‘mode: I determines whether form wil be modal 9¢ todeles(optional argument) thas tr Values: O-Modeless (default, I-Modal Modeless forms (oy default allow wser to switch to any ‘other form presen in the application or throughout the system. Thus user an intra freely withthe system, Mot fms oo ny ation me eter iss thane frm tse Mee Comp aoenan son a may a ice fate Toth mem tose Oe close button). as ‘Tie Show mod brings speci fom on Topo xe other window. dees “Hide? method ‘The ‘Hide’ method is used to hide a form. If an ‘pplication consists of multi forms, user can hide therm thus making space for others, Also there ae rarely used {rms present in an application, they can also be hidden, Syntax: FormName Hide To ide a form within its own code, use: Me.Hide ‘When a form is hidden itis just put away ffom user's sight. Oe can sll access it and use its properties in code. ‘The Hidden foms remain in memory and o display these instaly, the Show method is used, ‘Visual Basie = into a prograt (q1.34 How to call procedar® 7 nw a proce can be ced ian propam no een |. By“CALL" key wr foowed by prosdure mame, syotax Call Exar: Calltesth : 2 Wis using “CALL” Heywor! also one can call simply by giving procedre mame. = pare test ia procedure name. Examples test 135 What I the difference between calling a procedure with CALL keyword and calling ‘without CALL keyword? ‘Ans. When one calls « prcoture ty using CALL keyword, exqueats re wb ences in parethesis. je Call test 5,3) re witht using the CALL toni wa be enclosed in 46 What do you understand by parameters oF arguments tn Paant Tie mies oh in te psa Aehinition we called pecametee ig ‘pane cal povanesens, 2 WADHWA's Selected Questions & Answers Private sub adds, ye) End sub “Here x andy are parameters or formal parameters, Argument: The vats o& va or aes given when ocedir oa fnction sealed ae Lovo egosens ‘or actual parameters, ” Call dab) Here and bare arguments or actual parameters. 137 Hw say value mechan diferent te ‘call by reference? Gere from Ans. Following ae the irc bt feces beeen ea by vase ccall by reference: cn ze... | properties ok 3 for. ussite al anegentcornn IPT ss oe tiie ent tt 0 Hig Ca ty bested ttn 2 artes eee es v8 Wer pe 8 Se diet 3. Conlon Conlon set va ta indicates fetter Counce br stent ingle ees os 4. MaxBatton and MinButton Maton rte ale which indicates that mbes 8 form fas a Maximize tuto ct net. Silay, ‘MaBoton runs value which indicates that whesBer 8 Sorms a Minnie baton o not. 5. BackColr and ForeColor Cie fam oy a dei ine Sritcatewitentecng matting 6. Windowstae Waewnas 5 Saree, msinn ie pony se se of Se Sor 4 Fone A tees Bort ogres i we we toe fon Be tn te ert BD Wreat are te stvantgen of esto 2 Ana. Tin srentages of wis 8 prceatore a + kétuction in en of roaren coe + Reduction in size of compiled code. + Frozyam becomes more maintainable. + Lani becomes more understandable. (01.40 What do you mean by scope of a variable? What are the different types of scopes? ‘Ans. scope ofa variable is basically the level of is visibiiy.. Scupe defies which sections ofan application can use @ ‘vtable ‘Various levels of scope tht are supported by VB are: 1. Local scope:- This scope implis that the variable can only be used inthe procedurtfunetion in which itis defined, 2. Module scope:- This scope implies that the variable ‘ean be used in all the proceduresffunction defined is the module which contains the definition for the variable, fs of form Basle nmon properties Te) HCA 2015 ras piscus : prope of 3 f0 ostningaretheor Ans Foto te form tile bat Tig Can iy ie te 7 ee sets the border style Of the form Cot ha be played on frm On 4 MaxBotton and Minton Maxbuton eu ae wc ne tne baton oF 0 Jeunes ume which nats hat wheter tes that whether ‘Similar Son his Minimize button orn 5. BackColor and ForeColor Colors oma form are usually stat design time, although | ‘nde canbe writen o change them at run 6. WindowState ‘The WindowStte prety determines how the form wl appear when displayed, It may sppear normal, minimiz| or maximized, ADH Selected Questions & Answers ap 7. Name ‘This property sets the name ofthe form, 8, Font A form's Font property i used to on the form, (Q1.39 What are the advantages of using a procedure? Set the foot to be sed ‘Ans. The advantages of wing & procedure are + Reituction in sizeof source code + Reduction in sizeof compited code, + Program becomes more maintainable, + Logic becomes more understandable. (Q1.40 What do you mean by scope of a variable? What ‘are the different types of scopes? ‘Ans.A scope ofa variables basicaly the level ofits visi ‘Scope defines which sections of an application can use a variable, ‘Various levels of scope that are supported by VB are: Local scope:- This scope implies thatthe variable ean only be used in the procedure/unction in which it is defined. 2 Module scope:- This scope implies thatthe variable an be used in all the proceduresfunction defined in the module which contains the definition for the variable igual Basic spe implies that a variable rout the aplication u? ‘MDUBCA 2016 + of a menu item, They menu is one that branches of y Tarow to indicate that there is an extra You will have seen these plenty of times |. Global scope This tensed globally ie ‘qui What do you mean by sub mena Ans. s0b ‘sally have a menu avaiable. in Window programmes. 12 How general procedure is different from event’ driven procedure? user for ene that i ete by Ans penal proce te A One general posers die it 2 aly oked byte epiaon whenever Seu te neve ped roc rato an ej His tamed ina way tht wrens he oat nd the even ear For example tae even pect tke command baton ned ondVe i ror cmdView Click, vent preetre ercutavtmatlywhen te even eae. Q1.43 Write the use of MsgBox() and InputBox() functions in Visual Basic. xe associated with the ‘Ans. The MsgBox function is used to get Yes or No response from users and also to display some messages ina dialog box. While InpuBox function is used to accept data from the user WADHWA's Selected Questions & Answers __41. SR Scioto Questions & Answers at (QL.44 Discuss one dimensional and multi-dimensional arrays in detail. ‘MDU BCA 2018 ‘Ans. One-dimensional Array An array in which each element can be referred by one subscript or index is known as one-dimensional array. ‘The Dim statement is used to declare an aray Its syntax Dim arrayname (sie) As typename For example Dim Marks(10) As integer ‘This statement defines an array Marks that can store maximum 11 integers, ranging from Marks(O) to ‘Marks(10) The syntax of accessing data from an array is srayname(indes) For example, to set Marks (7) equal to 10, the statement is: Marks (2)= 10 Visual Basic also allows the feilty of specify ity of specifying the lower bound other than 0 using the To keyword. The general syntax is Dim ArrayName ((LowesSeript To] UpperSerip) As Datatype For example: Dim Marks (5 To 10) As integer This statement creates an aray of 6 integer variables ‘ranging from Marks (5) to Matks (10), After assigning values to array items, one can perform the tasks like sorting the array items into alphabetical oF cy visual Basic sing and changing the value | om, and passing the SOUP of ‘visual Basie Fonction op merical order, ace Misignd to each aay i en av proce @ Vist Bt eproutine by passing just the aay obi panera a Acton seis own a at canon ree te daa in abr of mat for, 1 | lozenional array is needed and ¢0 sfore Sequences of | | ‘multidimensional dats, oli ist index represents the row imensional array is needed, In two dimensional ary, fi and the second repesens the column. The following |: Statement declares 2 o-dimensional 50 by 50 aray | within procedure. Dim Aves (50, 50) Ivis also possible to define the lower limits for one or both he dimensions. For example Dim Marks (101 To 200, 1 To 100) ‘An example for thee dimensional-array with defined lower limits is given below Dim Detaits( 101 To 200, 1 To 100, 1 To 100) ‘This statement creates a three dimensional aray Det ith ies (1005100100) WADHWA's Selected Questions & Answers 43 2 ADU Selected Quantone & Anewere 43 Q1.45 What are Events? What are Event Procedures? How are they related? ‘Ans. Event refers to the occurence of an activity usually in response tothe user's ation, suchas a key press, mouse button click or a keystioke. Event procedures are procedures that are ealed when a corresponding event ‘eeurs. An event procedure is executed when the event connected with it takes place, QL46 What is the use of comments in VB? How is a comment written? ‘Ans, Programmers insert comment inthe code of application Programs 10 improve the readabiliy. Comments help other viewers to read and understand the program code. Comments are not visible at Run time. They do not perform any setion when a program is un. A comment begins with ether * or Rem, Q1.87 What isa form in VB? ‘Ans. A Form is # contol which serves as a container for other controls. It is the place where the user =:aiace is designed. Forms are the foundation and play a vital ole in creating the interface of an application. It tells user how a window screen would look when the progeam runs. Q1.48 Discuss about menu bar and toolbar in detail. MDUBCA 2018 ‘Ans. Menu Bar Menu bar is a medium which provides a way to perform Various actions. It displays the commands that are x appiation. tis played below the fs ist of men options of commands Hike File, Edit, View, jot pefom almost vent nes a required to build an “Title bar and includ Menu bar consists Project ete. These com trrnd of etn Each ne pin on Rtas down isto mena tems it are to the menu option. Toolbar Toolbar allows user a quick acess 0 the commonly used ‘menu commands, ‘The Standard Toolbar contains «set of buttons that nt featores. For represent all the major projet development fe ‘example, it may include some funtional buttons like Add Project, New Form, Open Project, Save Project, Show ‘Toolbox and Show Properties window. ‘The standard toolbar is present just below the menu bar and is displayed by default as shown below: WADHWA's Selected Questions & Answers___45 store & Aner 4S ‘There are also some adktional toolbars that can be added to the VB IDE from the view menu, These additonal toolbars” are provided for specific purposes such .s editing, form design and debugging. To view the auditona toolbars, choose View —» Toolbars. ‘The Edit Toolbar contzns the commands of the Edit Ment Bawie KE OIA ‘The Debug toolbar contains the commands of the Debug Menu +19 OFES OO Bee ee eee er eke) ‘The Form Eilitor toolbar contains the commands of the Format menu, B%E-B-a- @ Q1.49 Compare and contrast an access key and a short cut key? ‘Ams. Both access keys and shortcut keys help in simplifying the menu acess. Accesskeys ae used to open a menu by Pressing Alt+“leter’ key. Pace ampersend (8) character before a leter in Name property to make it accéss key. ‘The shorteut keys are used to perform a specific task ‘assigned to them, immediately when presse. a , Me and a i aveen a function (Q1.50Ditferentiate bet subroutine: sn faetion and ‘Ans Following are the diferenees botwes routine: Function 1A function returs 9 ingle le back (0 aeeSnoeprocedure | hc eling nocdors data | 2 Subroutine does not 2. Function has type that species the | havea data pe Spear vate, | Deeatse the can not way. isc by | 3 sbrout Pf one | scale nth aii mane aa i yume (on nah ay ot he taresion = QUI Compare Form Load event and Activate event, ‘Ans.Following points show the comparison between Form Load event and Activate event + Activate event oceurs after the Form Lond event. + The Activate event serves as a better place than the Form Load event to enter the startup code. This ‘ode affects form's appearance, If user places this Startup code in Form Load event procedure then WADHWA’s Selected Questions & Answers 47 eats a Anewore 7 some code (code that would manipulate run time ‘control properties) can eause a ran time error. + Form Load events fred only once when a program As run. The Activate event can be fired multiple times “after the form gets lode. (Q1.52 Differentiate statement? between Hide and Unload ‘Ans. To remove a form from seren, user can either hide it oF unload it. Following are the differences between Hide and Unload statements Unload 1, When one hides a form, | 1. When one unloads a the form is removed | “form, the “form ig from the sereen but it} removed from.” the Femains in the memory | screen and. also and occupies system] removed from ‘the Fesourees. ‘memory thus, releasing system resources and making them available for further use, }2-In hide “method, the | 2. tn unload method, the form becomes invisible | application is but the application is | terminated thus still running, ‘making the form invisible, ‘Ths if a form is used rarely, itis best to unload it rather ‘han hide it Frequent unload i also not prefered. are created in VB? more statements that | of one oF | = o, whether BY an event performs 3 ous tow procedures bk of 8 art sacmens which a. Ps 2 foe ene al iene 007 seated ean we awacdin VB by wing ft0HIng Wo - _ 1, Outside any other procedure, followed by End Sub statement 2. Inside the Sub statement, the Sub keyword is | can ay name of proceute and then the parame ist enclosed in pees. | 3, The coe of pede i plised between Sab and | End Sub serents To createa procedure which returns value procedure which does not return a val vse Sub statement, | 1, Outside any other procedure, use a Funetion | statement, followed by End Funetion statement. | / 2. Inside the Funetion siafement, the Function keyworé is followed by name of procedure and then the parameter list enclosed in parentheses accompanied by As clause which specifies datatype of the retum vale, 3. The code of procedure is placed between Function and End Function statements, 4, Use Return statement to return the value 10 the calling code WADHWA’s Selected Questions & Answers ___49) WADHWA'S Selected Quesions 6 Answers. 47 QL54 Differentiate between List Box control and Combo Box control. Ans. Following are the differences between List Box control and Combo Box conto i aoe List box allows | 1. Combo box . allows selection of multiple | selection of one item sms in thelist. only. 2. List box does not | 2. Combo box includes a include a text box on | text box on the top of the top. alist box. 3. Iallows user to select | 3. 1t allows user to items from the list, specify items that do not exist fi thelist. }4. A. listbox. control | 4. A combo box control displays the whole list’ | “displays one line with fon sereen and thus | Selected item and thus aceuples more space. | occupies less space. Q1.55 What are the four toolbars in VB6.0? ‘Ans. Following are the four toolbars in VB6.0: 1. The Standard Toolbar: It is present just below the ‘menu bar and is displayed by default % ‘The Edit toolbar: 1t contains the commands and items of the Bait Menu, 3. The Debug toolbar Debug Mens, ‘The Form Baditor Menu: It contains the commands ofthe Format Menu, It contains the commands of the yBox and TnputBox ate between MSE 50 se ie : in diffe between MsgBox and ae ees Am Fallwine #8 Tonner ii a Taam Se opus fo TAs the name explains it is a mechanism 0 sow small dist box, which pops cover the. essing Sppliation fT displaying custom messages. 2. Message Box ea alo bbe use to gather user responses but it 1s imited tothe User actions such 35 ‘whether the user has Clicked OK button, for Cancel Button oF Yes button of No button ete 3. Example MsgBox" displaying 2 message Silom, with collecting User Inputs. 2. The Input Box gathers ser data on string form. 3. Example: " Dim Age Age-InputBox("Enter Age") QUST What is the difference between Caption and [Name property? ‘Ans. The Caption property is used to set the test to be isplayed on the contra WADHWa’s Selected Questions & Answers 51 _wZ.s se “The Name property specifies the name of a control to be used in coding. A control name serves as an identifier tased to access that control in code. arrays. [DU BCA 2018 | quseiterenate between state arrays and dynamic ‘Ans. Following are the differences between static and dynamic ‘Static Array ‘Dynamic Array | 1. A statie array isan array which has a specific size. 2. Static ‘array is used ‘when it is known in advance how big the array should be. 3.The size of 2 statie ‘array is specified in ‘declaration statement of the array. For example, statement: “Dim Fruits(10) As String? declares a | static array called ‘Fruits that is made up of 10 elements. 1A dynamie array is an array whose size can change/vary. tobe determined each time the procedure 3. To declare a dynamic no number the parentheses after the-array name. For example, statement: “Dim Fruits) As String” declares ~ a | ynanie array called | Bruits Q1.59 What are Menus? ‘Ans.Menus are one of the most common and characteristic elements of the Windows usr interface. Menus are used 52 Visual Basi ies and guide th soy mtoially eran ch ‘pide the an application. sper ious a? Se, dil ase res me hi ws i ye Bai provides Ment Er rok 7 es We met 28) ncaa a ish ange an dete exiting ens. css jon Explicit fer? quan wit des Ot” EAP TT on pong i stement is that which ensures whether remus all variables 10 be expliciy Tete it use in the program. The Option estan olen variable delaratons, sop Ba whe colt decaredo94 pl py 28 pin Elta two odes ~On and OL moe, coi Explicit mode i ON, you have to declare nt etfs yor we em ie propan ‘toatl pneae a compile-time err whenever ts vrble tat has nt been declared is encountered, tithe Option Explicit mode is OFF, VB automatically ‘ets avaible whenever it ees a variable without rope declaration By defile the Option Explicit is On. With the Option Explicit On, you can educe the possible errors that result from aisspeled variable names because in Option Explicit On mode, you have to declare each variable in the progam for storing dats Q1.61 Differentiate hetween image ox and picture box controls, WADHWA's Selected Questions & Answers ‘Ans. Following are the diferences between image box and picture box conto ia 1. Tinage Box allows user | 1, Picture Box allows fo place graphical | “user to place images mages on a form.| as well’ as other Thus it eannot act asa | controls on a. form. container control, Thus it acts as a container control. 2. It is sulied for static | 2. 1 allows the user to “situations. Tt doesn't | ~ modify and edit the allow the user to | graphics information ‘modify the graphies | placed. placed. 3. Image box does not | 3. Picture box supports support the graphies |” advanced graphics hhandling methods. handling methods. 4-tmage box uses | 4. Picture ox uses Stretch property to |” AutoSize property 19 thake a graphics mt to | automatically resize a “Tmage controt’s siz. | control so. that its entire contents. are displayed. | Picture box uses more 54 pe Timer Conttol “onl which executes code neva specified. Te wale manany as vale #8 O. Te Mie, pulse to He cUEnt 1.62 Desert contol 8 secon © te sot a8 Ansa Tin ‘eyes al most ae js to send a pene’ tis insist 4 Oe = write interesting programs ne ver sel or de. TIMES vions periodically. cnt allows ew ies of © quae a ge tc seid Te ct Se ere om (Q1.64 What are Modules? ms Modoles are callestion of code and data that funcoe onething like objects in Object Oriented Programming, tut without defining OOP charctristes like ineritanes, polymorphism etc. The concept behind modules is 1 Enclose procedures and data In a°way that hides them: from the est ofthe program. QU.65 What is the use of Exit’ statement? Ft Ans, The Ext statement allows t exit prematurely from 2 ‘oc of stent in a contol structure from a oop ven froma procedure. Suppose ther is & For..-Net _ | | | | | Quoations v0 The quire wot Fo tha eet the si ragative ners cmt be cae aa ‘rv ext the lop premativey, ase Ub Het Ho siatenent a follows For io to Uloundend 990) ray) then Hat or Array(D=SqrnAtray() ment is ound in this loop. the program exits the loop and continues with the staten following the Nex statement, Q1.66 What are the common properties of the Controls in Visual Basie’ ‘Ans. The following properties apply to most ofthe controls: ‘Name: It sets the name of the control, through which fone can access the control's properties and methods via coding. “Appearance: It canbe set to 0 fora flat look or I fora 3:D look ofa control. + Back Color: It sets the background color on which text is displayed or graphics are drawn, ‘Fore Color: It ses the foreground color, * Font: I specifies the font face, attribute, and ste of the text displayed on the contol, ee ee a cox tat 8 st me cp forex Pate cont the lye 08 the a and Baton como eae anatis entered onthe contol wich ae input, for ‘example, the TextBox Sts i «swath & Heights Tes PE