18.01.2013 Views

Visual Basic Tutorials - Nadaun(District-Hamirpur)HP

Visual Basic Tutorials - Nadaun(District-Hamirpur)HP

Visual Basic Tutorials - Nadaun(District-Hamirpur)HP

SHOW MORE
SHOW LESS

You also want an ePaper? Increase the reach of your titles

YUMPU automatically turns print PDFs into web optimized ePapers that Google loves.

Om Edutech Institute Of IT & Applied Technologies <strong>Hamirpur</strong>(H.P)<br />

<strong>Visual</strong> <strong>Basic</strong> 6.0 <strong>Tutorials</strong><br />

Short Type Questions<br />

Q1.Three edition of <strong>Visual</strong> <strong>Basic</strong> are<br />

Ans. Leaning, Professional, Enterprise<br />

Q 2.The .frm is extension of<br />

Ans. Form<br />

Q 3.The .vbp is an extension of<br />

Ans. Project file<br />

Q 4.Methods are inbuilt function<br />

Ans. True<br />

Q5.Form is a container object<br />

Ans. True<br />

Q6.The title of the form can be change by property text.<br />

Ans.False<br />

Q7.An object always has<br />

Ans.Properties, Events, methods<br />

Q8.A standard module has an extension<br />

Ans. bas<br />

Q9.AddItem is used to manipulate the items in<br />

Ans. List box, combo box<br />

Q10.Form module only contains forms.<br />

Ans. True<br />

Q11.We can’t change the color of the command button.<br />

Ans. False<br />

Q12.Strandard module can contain forms.<br />

Ans. False<br />

Q13.A variable declare as string can store both.<br />

Ans. Numeric and characters.<br />

Q14.A dynamic array can be declared by<br />

Ans.redim<br />

Q15.A Boolean data type stores on true/false<br />

Ans.ture<br />

Q16. The bye data type has the range from 0 to 255.<br />

Ans. True<br />

Q17.Name the function, which is used to compare to string.<br />

Ans. strcmp( ).<br />

Q18. Name the function, which return the intervals between two dates in term of years, month, days?<br />

Ans. Datediff.<br />

Q19.Name the function returns length of string.<br />

Ans.len<br />

Q20.A module level variable is available to procedure in the module<br />

Ans.true.<br />

Q 21.Code window consist of an object box and procedure list.<br />

Ans.true.<br />

Q22.Name the event when the user closes form.<br />

Ans.unload.<br />

Q23.The ______ show method is used to display the form object.<br />

And. show<br />

Q24.Name the function gives you the day of week.<br />

Ans. weekday ()<br />

Q25.While loop executes the blocks of the statement as the condition is<br />

Ans. True<br />

Q26.The for statement is dependent on counter.<br />

Ans. True<br />

Q27.the counter variable is optional to specify with Next keyword.<br />

Ans. True<br />

Q28. ______ Is display as horizontal line between items on a menu bar.<br />

Ans. Separator bar.<br />

Q29. A check mark can be placed on a menu item using _______property.<br />

Ans. Check<br />

Q30. ______and _______ functions are used to add predefined dialog box.<br />

Ans.Inputbox () and Msgbox ().<br />

Created By:- Ajay Verma


Om Edutech Institute Of IT & Applied Technologies <strong>Hamirpur</strong>(H.P)<br />

<strong>Visual</strong> <strong>Basic</strong> 6.0 <strong>Tutorials</strong><br />

Q31.The event occur when user enter a standard ASCII characters.<br />

Ans.keypress<br />

Q32.The ________event occur when user presses any mouse button<br />

Ans. Mouse down<br />

Q33.Mouseup event occur when the user presses the mouse button.<br />

Ans. false<br />

Q34.OLE stands for Object Linking and Embedding.<br />

Ans true<br />

Q35.The P-code stands for _______code.<br />

Ans. Pseudo<br />

Q36.The quick watch value dialog box shows the ________the expressions.<br />

Ans. Value<br />

Q37.Debug.print the value on the form.<br />

Ans. False<br />

Q38.A Runtime error occurs only after the application starts the executions.<br />

Ans true.<br />

Q39.Code that handles runtimes errors is called an _______.<br />

Ans Error Handler<br />

Q40.The Auto Size property of a form automatically sizes the picture load to it.<br />

Ans. True<br />

Q41. The line method can be used to draw rectangles.<br />

Ans. True.<br />

Q42. ___________Functions specifies the files name assigns the picture to the picture property.<br />

Ans. load picture<br />

Q43.The point method returns the ________of a particular pixel.<br />

Ans. Color<br />

Q44. _______ Event occur when the size of the form is change.<br />

Ans. Resize<br />

Q45.DAO provides a framework for using code to manipulate__________.<br />

Ans database<br />

Q46. _____________Are the object that represent collection of records.<br />

Ans .recordset<br />

Q47.Name the three type of recordset.<br />

Ans. dynaset, Snapshots, tables<br />

Q48.Recordset objects contain sets of records from the database.<br />

Ans. true<br />

Q49. SQL is an abbreviated form of Sequential Quick Language.<br />

Ans. False<br />

Q50. RDO is an abbreviated form of Relational Data Object.<br />

Ans. false<br />

Q51.DAO can use OLEDB.<br />

Ans . false<br />

Q52.ODBC stands for.<br />

Ans . Open database connectivity<br />

Q53.OLEDB stands for.<br />

Ans . Object linking and embedding data bound<br />

Q54. ADODC stands for.<br />

Ans . Active x data object data bound<br />

Q55.API stands for.<br />

Ans. Application Program interface<br />

Q56.COM Stands for.<br />

Ans. Component object model<br />

60. Object is the instance of ___________.<br />

Ans. Class<br />

61.DLL are __________components.<br />

Ans .in process<br />

Q62.Exe ‘s are _______components.<br />

Ans . Out of process<br />

Q63. ___________Is a process involving a minimum of two independent entities, one being the client<br />

and the server.<br />

Ans client server architecture<br />

Created By:- Ajay Verma


Om Edutech Institute Of IT & Applied Technologies <strong>Hamirpur</strong>(H.P)<br />

<strong>Visual</strong> <strong>Basic</strong> 6.0 <strong>Tutorials</strong><br />

Q64. The code in an application can be broken into logical components by______process.<br />

Ans .partioning<br />

Q65.The seek method can be used to locate a record in a Dynaset type recordset.<br />

Ans. false<br />

Q66. Quertdefs is a collection of a table object that contains the detailed definition of each data table<br />

in the database.<br />

Ans. False<br />

Q67.A _________is a collection of object classes that the model the structure of relational database<br />

system.<br />

And. Data Access Object<br />

Q68.The ______________Object is a stored query definition, which is a precompiled SQL statement.<br />

Ans. Querydef object<br />

Q69. __________ Are SQL statements that perform specific actions on the database.<br />

Ans. Action Queries<br />

Q70. The ____________method creates a connection between the application and the ODBC<br />

database and assign it to a database type object.<br />

Ans. Open database<br />

Q71.The data control implements data access by using the____________.<br />

Ans. Microsoft Jet engine database<br />

Q72.The visual basic supports three transaction methods such as beginTrans, CommitTrans, and<br />

rollback.<br />

Ans .True<br />

Q73.The Add method of the recordset object is used to add a new row to the record set.<br />

Ans. False<br />

Q74.OLE control is a custom control.<br />

Ans.True<br />

Q75.An OLE control can hold only one object at a time.<br />

Ans. False<br />

Q76. ____________Method is used to display the insert object dialog box.<br />

Ans .InsertobjDig.<br />

Q77. ______Method creates an embedded object at run time.<br />

Ans .CreateEmbed<br />

Q78. Linked objected can be created using _______and ________methods.<br />

Ans . InsertObjdlg, CreateLink<br />

Q79.Polymorphism is the concept of combining of data and characteristics in a single package.<br />

Ans . False<br />

Q80.Inheritance property of object is not supported by <strong>Visual</strong> <strong>Basic</strong>.<br />

Ans. True<br />

Q81.Designing an ActiveXcontrol is similar to designing classes.<br />

Ans. True<br />

Q82.Exitfocus event is similar to Getfocus event.<br />

Ans. False<br />

Q83.The writeProperty method is used to stored a property value.<br />

Ans True<br />

Q84.The user will not be able to read the caption without the Getl1Caption procedure.<br />

Ans. True<br />

Q86.The ______method is used to read a value of a property of the control from the container form<br />

file.<br />

Ans. ReadProperty<br />

Q87.An active X project is compiled the same way a Standard EXE project is compiled.<br />

Ans. True<br />

Q88.An active X DLL is an out of process server.<br />

Ans. False<br />

Q89.An active X EXE , otherwise known as an _______server.<br />

Ans. Out of process<br />

Q90.Active X components are _______designed to be used with other application.<br />

Ans. objectserver<br />

Q91.In case of an in process server, the communication to client can be much can be faster than an<br />

out of process.<br />

Ans. True<br />

Q92.An out of process server runs n the same machine as its client and it can not be moved.<br />

Ans. False<br />

Created By:- Ajay Verma


Om Edutech Institute Of IT & Applied Technologies <strong>Hamirpur</strong>(H.P)<br />

<strong>Visual</strong> <strong>Basic</strong> 6.0 <strong>Tutorials</strong><br />

Q93.Recordset objects contain a set of records from the database.<br />

Ans True<br />

Q94. The counter variable is optional to specify with Next keyword.<br />

Ans. True<br />

Q95. ______ is display as horizontal line between items on a menu bar.<br />

Ans . Separator bar.<br />

Q96.. A check mark can be placed on a menu item using _______property.<br />

Ans. Check<br />

Q97.A Runtime error occurs only after the application starts the executions.<br />

Ans true.<br />

Q98.Code that handles runtimes errors is called an _______.<br />

Ans Error Handler<br />

Q99.The AutoSize property of a form automatically sizes the picture load to it.<br />

Ans. True<br />

Q100.A dynamic array can be declared by<br />

Ans.redim<br />

Q101. List few Properties of Text Box Control?<br />

Ans. Maxlength, Multiline, ScrollBars<br />

Q 102 List Three important properties of CommandButton<br />

Ans: Caption, Picture, and Sytle<br />

Q103. Triggers are used to maintain _______data.<br />

Ans: Integrity<br />

Q104. Change can be made to a record by using just edit method.<br />

Ans : False<br />

Q105 Active X Control has_____file name extension.<br />

Ans: .ocx<br />

Q106. Define Querydef.<br />

Ans : Querydef object is a stored Query definition which are precompiled SQL statement.<br />

107 Q Write graphic method to draw a line<br />

Ans line (600,600) – (2000,2000)<br />

Multiple choice questions<br />

1. What custom control file must be added to toolbox to use a Toolbar?<br />

i. Windows common controls 2(MSCOMCT2.ocx) file<br />

ii. Cool.exe<br />

iii. Windows common controls (Coolbar.ocx) file<br />

iv. None of the above<br />

Ans. iii<br />

2. What does MDI stand for?<br />

i. Master Document Interface<br />

ii. Multiple Document Interface<br />

iii. Master Data Interface<br />

iv. Multiple Data Interface<br />

Ans. ii<br />

3. To display “the first program” in the form’s title bar at the run time, what property of the form needs<br />

to be set?<br />

i. Name<br />

ii. Caption<br />

iii. Windowwstate<br />

iv. Tag<br />

Ans. ii<br />

4. In the statement “Dim abc as string” , Dim is:<br />

i. datatype<br />

ii. variable<br />

iii. constant<br />

iv. none of these<br />

Ans. iv.<br />

5. To indicate a comment block in visual basic, we use...............at the start of line<br />

i. ‘<br />

ii. “<br />

iii. /*<br />

iv. //<br />

Created By:- Ajay Verma


Om Edutech Institute Of IT & Applied Technologies <strong>Hamirpur</strong>(H.P)<br />

<strong>Visual</strong> <strong>Basic</strong> 6.0 <strong>Tutorials</strong><br />

Ans. i<br />

6. Form events are triggered tin what order:<br />

i. (I) activate (II) load<br />

ii. (III) initialize (IV) terminate<br />

iii. (I), (II), (III) and (IV)<br />

iv. (I) , (III), (II) and (IV)<br />

Ans. iii<br />

7. What kind of variable has the broadcast scope?<br />

i. Public<br />

ii. Private<br />

iii. Dim<br />

iv. None of these<br />

Ans. i<br />

8. Can a MDI parent form display a child form as modal?<br />

i. Yes<br />

ii. No<br />

Ans. ii<br />

9. How to specify a field name inside the ADO statement that controls the spaces in its name:<br />

i. within ()<br />

ii. within []<br />

iii. within “ “<br />

iv. within ‘ ‘<br />

Ans. iii<br />

10. The.................statement evaluates a variable for multiple values, and then executes a statement or<br />

a group of statements, depending on the contents of the variable being evaluated.<br />

i. Simple IF<br />

ii. IF-Else<br />

iii. Select case<br />

iv. While<br />

Ans. iii<br />

11. If an arraylist instance has only four elements and the programmer trees to add a fifth<br />

element..............<br />

i. compiler will issue a warning<br />

ii. compiler will stop<br />

iii. the number of elements will increase automatically<br />

iv. the fifth element will be discarded<br />

Ans. iii<br />

12. How is the Variant data type speed compared with other variable types?<br />

i. Same speed<br />

ii. Slower<br />

iii. Faster<br />

iv. None of these<br />

Ans. ii<br />

13. What kind of error is generated in the following code?<br />

dim snhwage as single<br />

dim snhrs as single<br />

dim snyrwage as single<br />

snyrwage = 5500<br />

snhrs = 0<br />

snhrwage = snyrwage/snhrs<br />

i. runtime error<br />

ii. logical error<br />

iii. syntax error<br />

iv. none of these<br />

Ans. i<br />

14. What is the syntax for adding to a control array at run time?<br />

i. set index(n)<br />

ii. unload object (index)<br />

iii. load object (index)<br />

iv. set new index (n)<br />

Ans. iii<br />

Created By:- Ajay Verma


Om Edutech Institute Of IT & Applied Technologies <strong>Hamirpur</strong>(H.P)<br />

<strong>Visual</strong> <strong>Basic</strong> 6.0 <strong>Tutorials</strong><br />

15. What does COM stand in reference to VB for?<br />

i. COMMand<br />

ii. Command Object Interface<br />

iii. Component Object Model<br />

iv. Command Object Interaction<br />

Ans. iii.<br />

16. Which of the following is /are procedural languages?<br />

i. Cobol<br />

ii. Oracle<br />

iii. MS Office<br />

iv. None of the above<br />

Ans. i<br />

17. A VB project is given the extension...........<br />

i. vbp<br />

ii. prj<br />

iii. pro<br />

iv. None of the above<br />

Ans. i<br />

18. The commenting in VB is done with:<br />

i. ,<br />

ii. /**/<br />

iii. ”<br />

iv. None of the above<br />

Ans. i<br />

19. A variable name can be of length:<br />

i. > 255 characters<br />

ii.


Om Edutech Institute Of IT & Applied Technologies <strong>Hamirpur</strong>(H.P)<br />

<strong>Visual</strong> <strong>Basic</strong> 6.0 <strong>Tutorials</strong><br />

Ans. i<br />

25. Is the line valid in VB?<br />

i. Yes<br />

ii. No<br />

iii. Validity depends on version<br />

iv. None of the above<br />

Ans. i<br />

26. A.....................form is one which requires action from the user before it can be closed.<br />

i. modal<br />

ii. parent<br />

iii. child<br />

iv. None of the above<br />

Ans. i<br />

27. ......................may be used in Menu editor?<br />

i. &<br />

ii. &&<br />

iii. *<br />

iv. None of the above<br />

Ans. i<br />

28. Which String function is not defined in VB?<br />

i. LTrim<br />

ii. RTrim<br />

iii. Trim<br />

iv. None of the above<br />

Ans. iv.<br />

29. Method(s) defined for Clipboard object is/are:<br />

i. Clear<br />

ii. GetText<br />

iii. SetText<br />

iv. None of the above<br />

Ans. i, ii, iii<br />

30. Find the Correct line(s)<br />

i. 1 inch = 1440 twips<br />

ii. 1 inch = 72 twips<br />

iii. 1 twip = 1440 inches<br />

iv. None of the above<br />

Ans. i<br />

Do as directed<br />

a. Controls hold code that makes them respond to the user’s input.<br />

i. True<br />

ii. False<br />

Ans. False<br />

b. Caption property specifies the command button’s title?<br />

c. Properties support multiple events.<br />

i. True<br />

ii. False Ans. True.<br />

d. True/False property value determines if a check box is selected or not.<br />

e. More than one menu option can be checked at once.<br />

i. True<br />

ii. False<br />

Ans. True<br />

f. Properties can be set at Run Design time.<br />

g. The two methods by which arguments can be passed to a procedure are By value and<br />

By Reference<br />

h. DIM statement is used to declare arrays<br />

i. Database Name property of the Data control specifies the database to be used.<br />

j. Removeitem method is used to remove an item from the list.<br />

k. Form are the only objects that can have menus attached.<br />

l. To remove a command temporality from the menu set the command’s visible property to False.<br />

m. Addnew method of the Data Control appends a record to the table.<br />

n. Additem method is used to add items to the list.<br />

Created By:- Ajay Verma


Om Edutech Institute Of IT & Applied Technologies <strong>Hamirpur</strong>(H.P)<br />

<strong>Visual</strong> <strong>Basic</strong> 6.0 <strong>Tutorials</strong><br />

Short Type Questions<br />

Q1. What is event driven programming?<br />

Ans. In event driven programming the flow of program execution is controlled by the events that occurs<br />

as the program is running. Each time an event occurs, it causes a message to be sent to the<br />

operating system. The system processes the message and broadcasts it to the other windows.<br />

Each window can then take the appropriate action based on its own instruction for dealing with that<br />

particular message.<br />

Events can be triggered by user’s actions, by messages from the system or other application, or<br />

even from the application itself. The sequence of these events determines the sequence in which<br />

the code executes. Thus the path through applications code differs each time the program runs.<br />

Q2. Differentiate between a variable and a constant.<br />

Ans. Constant is a meaningful name that tasks the place of a number or string that does not change<br />

variable in a placeholder in memory. The value in variable can be modified.<br />

Q3. What do you mean by data type?<br />

Ans. A variable is the reference of area in memory, which holds temporary value. The value can change<br />

while an application is running. There are several types of variables, called data types.<br />

e.g.<br />

Integer, Long, Single, Double, Bytes, Boolean, String, Date<br />

Q4. Give the syntax of for loop in VB.<br />

Ans. For variable = start to end step value<br />

.<br />

:<br />

Next<br />

For example<br />

For I = 1 To 10 Step 1<br />

Print I<br />

Next<br />

Q5. What is a form in VB?<br />

Ans. A form is a window that contains an application code and has other objects placed on it to create<br />

the user interface. A form may fill the entire screen or have other forms contained within it or it may<br />

be a custom dialog box.<br />

Q6. What is difference between label and caption?<br />

Ans. Label is a control, which is used to display the text on it.<br />

Caption is the property of an object. It will also show the text, which is assigned to caption property.<br />

Q7. How will you define an array in VB?<br />

Ans. Array is declared by giving name to the array with the upper limit in the parentheses.<br />

e.g.<br />

Dim A (5) as Integer.<br />

Here A is array of type integer, whose length is 6 with index numbers running fro 0 to 5<br />

Q8. When will you use combo Box?<br />

Ans. Combo box is required when we want to show a list of items on form. It will show a list from which<br />

we can select one item.<br />

Q9. How will you define a menu hot key?<br />

Ans. Put & sign before the letter you want to make as hot key in menu editor.<br />

Q10. Give any two advantages of VB?<br />

Ans. We can develop graphical user applications.<br />

It can be attached with any database.<br />

Q11. Why should you change the control names from their default values?<br />

Ans. Default name put number following name of control. It is original practice to change the name of<br />

control according to its respective usage in the application. It will also help in proper<br />

documentation.<br />

Q12. What is difference between decision statement and a looping statement?<br />

Ans. Decision-statement in used to check the condition and then execute a group of statements if<br />

condition is true. The group is executed once whereas looping statement is used to execute a<br />

group of statement more then once till the condition is true.<br />

Q13. Differentiate between a checkbox and an option button.<br />

Ans. Check box more than one in an application can be checked where as in case of option buttons only<br />

one from a group can be selected.<br />

Q14. What is difference between Now and Time function?<br />

Ans. Now function retrieves date and time where as Time function retrieve time only.<br />

Q15. What does ODBC stand for and what is its purpose?<br />

Created By:- Ajay Verma


Om Edutech Institute Of IT & Applied Technologies <strong>Hamirpur</strong>(H.P)<br />

<strong>Visual</strong> <strong>Basic</strong> 6.0 <strong>Tutorials</strong><br />

Ans. Open database connectivity is windows technology that lets a database client application connect<br />

to an external database.<br />

Q16. What is difference between linking and embedding?<br />

Ans. Data associated with a lined object is stored by the application that supplied the object. This<br />

application stores an only link reference that displays a snapshot of the source data.<br />

When an embedded object is created all the data associated with that object is contained in the<br />

object.<br />

Q17. Describe difference between testing and debugging.<br />

Ans. Testing is the procedure to check the application if it is working properly and according to the<br />

requirements specified before coding.<br />

Where as Debugging is the technique to find errors and removing them, so that the application<br />

could work properly.<br />

Q18. What is the purpose of a toolbar in an application?<br />

Ans. It contain several controls that are used t place on a form at design time there by creating the user<br />

interface area.<br />

Q19. What is MS flex Grid control? And why is it used?<br />

Ans. A MS flex Grid control in VB is used to create applications that present information in rows and<br />

columns. It displays the information in cells. The user can select a cell at run time but cannot<br />

change the contents.<br />

Q20. What do objects of same class share?<br />

Ans. Objects of same class share all public members of the class.<br />

Q21. What control draw circles on the form?<br />

Ans. Shape control is used to draw circle.<br />

Q22. What data binding is and how does it work”?<br />

Ans. Data binding is the procedure of including code of other files, which are actually not the part of<br />

current applications code. These are DLLs, which are either predefined or made by the<br />

programmers.<br />

Q23. Differentiate between control array and control collection.<br />

Ans. Control array contains no of controls but of same type where as control collection in group of<br />

controls of heterogeneous type i.e. varying controls are the part of a control collection.<br />

Q24. What are the two controls needed when creating toolbar?<br />

Ans. First is windows common control<br />

Second is image control.<br />

Q25. How are form templates useful when creating a toolbar?<br />

Ans. Templates is used to choose the form type. For example. MDI form, from;<br />

Q26. Write down the various kind of Data type in <strong>Visual</strong> <strong>Basic</strong> and how much memory it will<br />

occupy in the main memory.<br />

Ans. Integer 2 bytes<br />

Long 4 bytes<br />

Single 4 bytes<br />

String 1 byte<br />

Byte 1 byte<br />

Date 8 byte<br />

Variant 16 bytes<br />

Double 16 bytes<br />

Q27. Write down various in functions with example.<br />

Ans. These functions are procedures that return a value. Three categories of functions are Date and Time<br />

function, Format function, and String function<br />

1.Date and Time functions: Date and time are internally stored in visual basic. The system current<br />

date and time can be retrieved using now, date, and time function in VB i.e<br />

Year (NOW)<br />

Month (Now)<br />

Day (Now)<br />

Datediff function returns the interval between two dates in terms of years , month or days.<br />

Format functions<br />

The format function accepts numeric values and converts it to string in the format specified by the format<br />

argument.<br />

Format (expression [, format [, firstdaydayof week]])<br />

String Function<br />

VB string functions can manipulate strings in application.<br />

Strcmp() Compare two strings<br />

Len () find the length of string<br />

Created By:- Ajay Verma


Om Edutech Institute Of IT & Applied Technologies <strong>Hamirpur</strong>(H.P)<br />

<strong>Visual</strong> <strong>Basic</strong> 6.0 <strong>Tutorials</strong><br />

Lset(),Rset() justify the string<br />

Q28.Write a note on Msflexgrid.<br />

Ans. A MS FlexGrid control in <strong>Visual</strong> basic is used to create application that presents information in row and<br />

columns. It displays the information in cell. The user can select a cell at run time by clicking it or by using the<br />

arrow keys , but cannot the edit or alter the cell’s contents. The MSFlexGrid control displays and operators<br />

on tabular data. It is necessary that we add the MSFlexGrd.ocx file to our project before we use a<br />

MSFLexGrid control in our application.<br />

Q29.Differentiate between MDI and SDI<br />

Ans. Single Document Interface is an application that can support only one document at a time.<br />

Multiple Document Interface allows you to create an application that maintains multiple forms within<br />

single container form. An MDI application allows the user to display multiple documents at the same time<br />

with each document display in its own windows.<br />

6.List three important properties of command button.<br />

Caption: This property specifies the text that appears on the command button.<br />

Picture: This property specifies a graphic image that appears on the command button in place of caption.<br />

Style: This property specifies whether a command button display a text caption or picture.<br />

Q30.Define the term ADO.<br />

Ans. This is a programming model that eliminates the need to choose from DAO and RDO and all other data<br />

access models. It is designed to provide a common bridge between different database, file systems and<br />

email servers.<br />

Q31.Define Recordset.<br />

Ans. A recordset is an object that contains sets of records from database.<br />

Q32.Write down various list controls.<br />

Ans. list box and Combo box:<br />

List and combo box control present a set of choice that are display vertically in a single column. If the<br />

number of items exceeds the value that can be displayed, scroll bars will automatically appear on the<br />

control.<br />

Q33. what are the variables and constants?<br />

Ans Variables are those whose value changes during the execution of program.<br />

Constant are those whose value does not change during the execution of program.<br />

Q34.What are exit for and exit do statements?<br />

Ans. Exit for and Exit do statement are used to terminate the loop before normal termination of loops.<br />

Q35.What do you mean by focus or control focus.<br />

Ans.The focus and control focus is the currently selected control. <strong>Visual</strong><br />

<strong>Basic</strong> indicates the control with the focus by highlighting the control.<br />

Q36.Explain immediate windows briefly.<br />

Ans. The immediate window is a window inside the visual basic environment in which you can view program<br />

values and print the message during the program’s execution.<br />

Q37.What is native code and P-code?<br />

Ans. visual basic used to produced executable program file in p-code i.e. (pseudo code – it is a technique for<br />

expressing operation of a computer program or an algorithm in a natural language such as English. It was<br />

develop as alternative to flowing chart) rather than native code. But with the later versions of visual basic the<br />

compiler started translating the visual basic, which people can understand, into executable programs<br />

consisting of native machine code that computer can read and understand.<br />

Q38.What do mean by breakpoint?<br />

Ans. A breakpoint works as marker in the code that tells visual basic to suspend program execution.<br />

Breakpoint is temporary and not preserved with in code.<br />

Q39.Explain the debug. print statement.<br />

Ans. The print Method sends output to immediate windows by including<br />

Debug. Print [item];<br />

Q40.Explain the checkbox control?<br />

Ans. A check box offers option for user. A checkbox is an option on a form that is checked when selected<br />

and unchecked when not selected. Use checkbox when you want to offer user two value choice.<br />

Q41.Write a note on inputbox function.<br />

Ans. The inputbox () function displays a model dialog box that asks the user to enter some data. The dialog<br />

box contains a message, an OK button and a cancel button. The first parameter of the inputbox () function is<br />

the message of the dialog box and second parameter is the title of the message box.<br />

e.g.<br />

n = input (“Enter your name”,”name please”)<br />

Q42.What is an array .How to declare an array.<br />

Ans. A sequence of variable by the same name can be referred using arrays. The individual elements of an<br />

array are identified using an index.<br />

Created By:- Ajay Verma


Om Edutech Institute Of IT & Applied Technologies <strong>Hamirpur</strong>(H.P)<br />

<strong>Visual</strong> <strong>Basic</strong> 6.0 <strong>Tutorials</strong><br />

e.g<br />

Dim salary (9) as integers<br />

Q43.Write the syntax of if then else statement in VB.<br />

Ans. The if…then block is used for conditional execution of one or more statements.<br />

If (condition) then<br />

Statement1<br />

Statement2<br />

End if<br />

Q44.Write syntax of select case in VB.,<br />

Ans. Select. …Case structure is an alternative to if…then.elseif for selectivelty executing a single block of<br />

statements from among multiple blocks of statements. Select. …Case is more convenient use than if… else<br />

…end if because it reduces the program complexity. A program is easy to read and follow.<br />

Select case index<br />

Case 0<br />

Statements1<br />

Statements2<br />

Case 1<br />

Statements1<br />

Statements2<br />

End case<br />

Q45. Define Dynaset and Recordset<br />

Ans. Dynaset Type Recordset<br />

The dynaset type recordset object is a set of records that records that represents a table, or attached table,<br />

or the result of queries containing fields from one or more tables. A dynaset enables us to update data from<br />

more than one table.<br />

Snapshot type Recordset<br />

The snapshot type recordset can refer to any table, attached table or query. A snapshot cannot be update<br />

and does not reflect any change made by users.<br />

Q46.Define ODBC.<br />

Ans. A standard protocol that permits applications to connect to variety of external database server or<br />

files.ODBC drivers used by the ODBC driver manager permit access to SQL Server and other Data source.<br />

Q47. Differentiate between procedural programming and event driven programming.<br />

Ans. Events are various things that can happen in a program .In the procedural language a written<br />

application in executed by checking for the program logically through the program statements one<br />

after the another. By in even driven application the program statement are executed only when a<br />

particular event calls a specific part of the code i.e. assign to the even. e.g. text box events are<br />

change, click, mouse move, etc.<br />

Q48. Describe the various mouse events.<br />

Ans. The main mouse events are mouse down, mouse up, mouse move. Mouse down occurs when the<br />

user presses any mouse button and mouse up occurs when the user releases any button. Mouse<br />

move event occurs whenever the mouse pointer is moved to the new point of the screen.<br />

Q49 Write a short note on combo box and their types.<br />

Ans: A combo box combines a features text box and list box. This control enables the user to select either<br />

by typing text in combo box or selecting by an in item from the list.<br />

Types of combo box<br />

1. Dropdown combo (style 0)<br />

2. Simple combo (style 1)<br />

3. Dropdown list (style2)<br />

Private sub form _load ()<br />

combo1. AddItem "MCA"<br />

Combo1.Additem "PGDCA"<br />

The add item method is used to add the value to the combo box and the list box.<br />

Q50 Write a note on IDE.<br />

IDE is integrated development environment, which is used in the programming to describe the<br />

interface and environment that we use to create our applications. It is called integrated because we<br />

can access virtually all the development tools that were need from one screen is called interface.<br />

Q51 Write down the various elements or components of IDE.<br />

Main elements or components of IDE are:<br />

• Menu bar<br />

• Tool bar<br />

• Project explorer<br />

• Properties window<br />

Created By:- Ajay Verma


Om Edutech Institute Of IT & Applied Technologies <strong>Hamirpur</strong>(H.P)<br />

<strong>Visual</strong> <strong>Basic</strong> 6.0 <strong>Tutorials</strong><br />

• Toolbox<br />

• Form Designer<br />

• Object Browser<br />

Q52 Discuss briefly about show method.<br />

Ans The show method is used to display the form object.<br />

e.g, form1.show<br />

Q53 Discuss briefly about unload statement<br />

Ans. The unload statement removes the form from the display and releases its memory. The following<br />

code should be entered<br />

Unload form 1<br />

Q54 write an applicable program by using text box and command button.<br />

Private sub command 1_click ()<br />

Text1. Text="This text box is locked"<br />

End sub<br />

The following code is entered in the command 2 buttons.<br />

Private sub command2_click ()<br />

End<br />

End sub<br />

Q55 Write an application by using Hscroll bar.<br />

Private sub cmdexit_Click ()<br />

End<br />

End Sub<br />

The following code is entered in Hscroll Change event<br />

Private sub HScroll_Change()<br />

Text1.Text=Str(HScroll1.Value)+"mph"<br />

End sub<br />

The following code is entered in HScroll Scroll Event<br />

Private sub HScroll_Scroll ()<br />

Text1_Change<br />

End sub<br />

Q56 Describe the various mouse events.<br />

Ans. The main mouse events are mouse down, mouse up, mouse move. Mouse down occurs when the<br />

user presses any mouse button and mouse up occurs when the user releases any button. Mouse move<br />

event occurs whenever the mouse pointer is moved to the new point of the screen.<br />

Q57. Write a code in <strong>Visual</strong> <strong>Basic</strong> to draw a box using graphic method.<br />

Ans Line (600,600) – Step (1000,0)<br />

Line – walk (0,10000)<br />

Line – Step (-1000,0)<br />

Line – Step (0, -1000)<br />

Q 58. Differentiate between procedural programming and event driven programming.<br />

Ans. Events are various things that can happen in a program .In the procedural language a written<br />

application in executed by checking for the program logically through the program statements one<br />

after the another. By in even driven application the program statement are executed only when a<br />

particular event calls a specific part of the code i.e. assign to the even. e.g. text box events are<br />

change, click, mouse move, etc.<br />

Q 59 What is native code and P-code?<br />

Ans. visual basic used to produced executable program file in p-code i.e. (pseudo code – it is a technique for<br />

expressing operation of a computer program or an algorithm in a natural language such as English. It was<br />

develop as alternative to flowing chart) rather than native code. But with the later versions of visual basic the<br />

compiler started translating the visual basic, which people can understand, into executable programs<br />

consisting of native machine code that computer can read and understand<br />

Q60 What are the various startup positions in the VB forms?<br />

Ans. Startup position property is used to set the position of the form when it gets displaced on the screen.<br />

Various options are:<br />

-1. Manual<br />

-1. Center owner<br />

-1. Center Screen<br />

-1. Windows default<br />

Q61 Explain the two tab of properties windows?<br />

Ans. The two labs of properties windows are:<br />

-1. Alphabetic<br />

-1. Categorized<br />

Created By:- Ajay Verma


Om Edutech Institute Of IT & Applied Technologies <strong>Hamirpur</strong>(H.P)<br />

<strong>Visual</strong> <strong>Basic</strong> 6.0 <strong>Tutorials</strong><br />

Sometimes it is convenient to display the properties sorted alphabetically. For this, alphabetic tab<br />

can be used. But sometimes you can group the properties according to their categories. For this,<br />

categorized tab can be used. e.g. categories can be appearance, behavior etc.<br />

Q62 What are various types of list box used in visual basic?<br />

Ans. List box control is used to display a list and terms can be added both at design time and run time.<br />

Following types of list box are provided in visual basic, which can be set through its style property.<br />

-1- Standard.<br />

-1- Checkbox<br />

Q63 What is the one major difference between list box control & combo box control?<br />

Ans. One major difference between list box & combo box control is that in combo box user can enter his<br />

own items whereas in list box user has to select only from the list provided & he can not enter his<br />

own items in the list.<br />

Q64 Write three important properties of command button?<br />

Ans. Three important properties & command button are<br />

0. Name: Name property of command button, which will be used in code windows while<br />

programming any event of command button, which will be used in code window while<br />

programming any event of command button.<br />

0. Caption: Caption property sets the caption of the command button which will be displayed on the<br />

button e.g. O.K. cancel button show in Microsoft products.<br />

0. Enabled: This property is either true or false. If it is true the user can click the button other wise if<br />

false then user is unable to click the button.<br />

Q65 What do you understand by term debugging?<br />

Ans. Debugging a program means correcting the errors in the program while it is running. Immediate<br />

window is used for help in debugging as a program is running in visual basic. IDE. Immediate<br />

windows helps to display the value of the program variables, change the value of the variables.<br />

During debugging, you can insert statement in the code, change the value of variable and then<br />

continue running your program<br />

Q66 Explain RGB() function ?<br />

Ans. For defining colors, visual basic provides the RGB() function, which accepts three arguments.<br />

RGB (Red, Green, Blue)<br />

With RGB() function, you can define any color. The red, green & blue arguments accept<br />

values from 0 to 255. e.g. to change the background color. The red, green & blue arguments<br />

accept values from 0 to 255 e.g. to change the background color, you can write form1.backcolor =<br />

RGB (255,255,0).<br />

Q67 Explain the difference between implicit & explicit declarations?<br />

Ans. In visual basic, there are two types of declarations implicit & explicit. In visual basic, you can<br />

choose not to declare variable & if visual basic sees an undeclared variable, it creates that variable<br />

& type of variable is variant. Such declaration is implicit declaration.<br />

Other type is explicit declaration where variables can be declared by Dim statement followed by<br />

variable's name and type e.g.<br />

Dim meters as integer<br />

For explicit declarations, statement option explicit should be written on top of the form.<br />

Q68 Explain the difference between Access keys & Shortcut keys.<br />

Access Keys Shortcut Keys<br />

1. Access keys starts with alt key 1. Shortcut start with ctrl key<br />

2. Access keys are designated by putting '&' sign 2. Shortcut keys are to be selected from the Menu<br />

in front of the letter.<br />

editor.<br />

3. If designer don't designate access keys. VB 3. There is no such rule for shortcut keys<br />

uses the first character as Access key.<br />

4. Access keys can be defined for command<br />

buttons, menus etc.<br />

Created By:- Ajay Verma<br />

Shortcut keys are only defined for menus.<br />

Q69 Write four important properties of listbox control.<br />

Ans. Four important properties of listbox control are:<br />

0. List (): This property contains all the elements in the list<br />

0. Listcount: This is the number of items in the list.<br />

0. Sorted: By setting this property to true, items in the list are always sorted.<br />

0. Style: This property determines the appearance of the control<br />

Q70. List three file controls used in visual basic?<br />

Ans. Three file controls used in <strong>Visual</strong> <strong>Basic</strong> are<br />

0) DriveList box: Displays the names of the drives within & connected to PC<br />

0) DirList box: Displays the folders of the current drive.


Om Edutech Institute Of IT & Applied Technologies <strong>Hamirpur</strong>(H.P)<br />

<strong>Visual</strong> <strong>Basic</strong> 6.0 <strong>Tutorials</strong><br />

0) FileList Box: Displays the files of current folder.<br />

Q71 Why Dim statement is used in visual basic?<br />

Ans. Dim statement is used in visual basic to declare any variable.<br />

e.g. Dim a as Integer<br />

Above statement declares a variable 'a' of the type integer.<br />

Q72 .Write note on variable naming conventions used in visual basic.<br />

Ans. Following are the few naming conventions used while declaring variables.<br />

0. Must begin with a letter.<br />

0. Can't contain an embedded period or any of the keywords.<br />

0. Must not exceed 255 characters.<br />

0. Must be unique within it scope.<br />

Q73. What is pop up menus?<br />

Ans. Pop up menus are also called context menu or shortcut menu that the user can invoke by right<br />

clicking a form or control. This pop up menu is regular menu & can be displayed anywhere on the form. Pop<br />

up menus are invoked with the PopUpMenu method.<br />

Q 74. Explain the difference between Modules & Class modules.<br />

Ans. Modules store variable declarations and code, which are available to all other components of an<br />

application. But if procedures are to be used in several projects then class Modules are built.<br />

Q75 List three important properties DateTimePicker control.<br />

Ans. Important properties of DateTimePicker control are<br />

0. Value: - This property gives the value of the date & time displayed n the control.<br />

0. Name: - Name property sets the name of the dtpicker, which is used in coding.<br />

0. Format: - It specifies the format of the date or time to be displayed in the control.<br />

Q 76. Write a note on MonthView control.<br />

Ans. MonthView control used to display a calendar that shows one or more months as specified. This control<br />

lets the user move from one place to another. You can also specify selection of dates and specified dates<br />

can be obtained from its value property. By default, the current month of the current year is displayed.<br />

Q77. Name the functions used to create menus with Bitmaps.<br />

Ans. Functions used to create menu with bitmaps are:<br />

0. GetMenu( )<br />

0. GetSubMenu()<br />

0. ModifyMenu( )<br />

0. CreateCompatibleDC( )<br />

0. CreateCompatibleBitmap( )<br />

0. SelectObject( )<br />

Q78. List four important properties of ListView control.<br />

Ans. Add – Adds a new item to listeners collection<br />

Count – Returns number of items in collection.<br />

Item – Retrieves an item specified by and index value or key<br />

Sorting – Whether the items of listview will be sorted or not.<br />

Q79. Explain the function GetDriveType( ).<br />

Ans. GetDriveType () function determines the drive type & is declared as private declare function<br />

Getdrivetype Lib “Kernel32” _<br />

Alias “GetDriveTypeA” (By Val ndrive as string) As long<br />

You pass the drive that you want to check with nDrive argument & function returns a long value, which<br />

describes the type of drive.<br />

Q80 Describe two ways of establishing a connection to database with ADODB.<br />

Ans. Two ways of establishing a connection to database with ADODB are:<br />

0. By passing the connection string to open method of ADODB.<br />

0. By creating a ‘dsn’ that can be passed to open method of ADODB.<br />

Q81 Define data integrity.<br />

Ans. Data integrity states that there should be no duplication of records & database should always be in a<br />

consistent state. Each record in the database should be uniquely identifiable.<br />

Q 82. Write two important properties of data bound list.<br />

Ans. Two important properties of data bound list are<br />

4. Row source – Specifies the source (recordset or data control) for populating the list.<br />

4. Listfield – Specified the field that will be used to fill the list.<br />

Q83. Explain TableDef object.<br />

Ans. A TableDef object represents the definition of table in database object. All TableDef object forms a<br />

collection, the TableDef collection.<br />

Created By:- Ajay Verma


Om Edutech Institute Of IT & Applied Technologies <strong>Hamirpur</strong>(H.P)<br />

<strong>Visual</strong> <strong>Basic</strong> 6.0 <strong>Tutorials</strong><br />

Q84. Explain QueryDef object.<br />

Ans. Database can contain query definitions. The queries that are commonly used on a database can be<br />

stored in the database & called by name. All the queries stored in database can be accessed through the<br />

QueryDef object. QueryDefs object is a collection of QueryDef object, one for each stored query.<br />

Q85. How SQL queries can be executed through active data object<br />

(ADO)?<br />

Ans. SQL queries can be executed through ‘Execute‘ method of active data object. E.g.<br />

ADOconn.Execute “Select * from employees”<br />

Q86. List the advantages of COM.<br />

Ans. COM is a language independent object model that defines many types of services & support for<br />

distributed objects. COM is the only model that provides detailed & open specifications & helps to provide<br />

stability, effective communication protocol & in process server support that developers & end user need.<br />

COM provides easy to use tools & largest set of available applications. It provides Help for reusable<br />

components. COM supports thousands of available applications.<br />

Q87. List two important properties of coolbar control?<br />

Ans. Two important properties of coolbar control are:-<br />

1. Orientation: - This property specifies the orientation of the coolbar. It can be horizontally oriented or<br />

vertically oriented.<br />

2. Align: - Align property specifies the alignment of coolbar control on its container object.<br />

Q 88. What is an active X control?<br />

Ans. Active X controls are user design controls, which have users specific properties.<br />

Q89. Explain the difference between intrinsic controls & ActiveX control.<br />

Ans. Intrinsic controls are those controls, which are there in the toolbox of visual basic whereas ActiveX<br />

controls are custom made controls, which can be build, by the users. Intrinsic controls are standard visual<br />

basic controls whereas you can make controls that have user specific properties. E.g. You can design a text<br />

box control which accepts only numeric values.<br />

Q90. Define Twip<br />

Ans. A screen independent unit used to ensure that placement and proportion of screen elements are<br />

same on all display systems. A twip is a unit of screen measurement equal to 1/20 of printers point.<br />

There are app 1440 twips to a logical inch or 567 twips to a logical centimeter.<br />

Q91. Write a short note on Microsoft Jet database engine.<br />

Ans. It is a database management system that retrieves stores data in user and system databases. The<br />

Microsoft Jet database engine can be thought of as a data manager component with which other<br />

data access systems such as Microsoft Access and visual <strong>Basic</strong> are built.<br />

Q92. What do you mean by DLL?<br />

Ans Dynamic link library. DLL is compiled version of coded. DLLs are components of applications<br />

that provide several functions in a file that can be linked to and used by a program when it is run.<br />

They are extremely useful for to reusing someone’s code or if we want our programs to be smaller.<br />

Q93. What is dynaset?<br />

Ans. A type of Recordset object that returns a dynamic set of pointers to a live database data like a table<br />

or a snapshot type Recordset, a dynaset returns data in records (rows) and fields (columns). Unlike<br />

a table type Recordset, a dynaset type recordset can be there result of a query that joins two or<br />

more tables.<br />

Q94. Define Event.<br />

Ans. An action recognized by an object, such as clicking the mouse or pressing a key and following<br />

which you can write code to respond. Events can occur as a result of a user action or program code, or they<br />

can triggered by the system.<br />

Long Type Questions<br />

Q 1.Write down the various control structure in <strong>Visual</strong> <strong>Basic</strong>.<br />

Ans :<br />

. Select Control structure<br />

Control structure are used to control the flow of program's execution. <strong>Visual</strong> <strong>Basic</strong> supports control<br />

structure such as If…. Then, If…. Then …… Else , Select ….. Case and loop structure such as Do<br />

While ….Loop, Do… Loop while and For ……Nest method.<br />

If…. Then … Else Statement<br />

The If….. Then block is used for conditional execution of one or more statements.<br />

If condition then<br />

Statements<br />

End If<br />

The statement is executed only if the condition is true. The condition is usually a comparison, but is can<br />

be any expression that evaluates a numeric value. If then – Else block is used to define several blocks<br />

Created By:- Ajay Verma


Om Edutech Institute Of IT & Applied Technologies <strong>Hamirpur</strong>(H.P)<br />

<strong>Visual</strong> <strong>Basic</strong> 6.0 <strong>Tutorials</strong><br />

of statements, in order to execute to one block. The following block of statement illustrates if…. Else..<br />

End if statement.<br />

if A =1 Then<br />

Statements<br />

Else<br />

Statements<br />

End if<br />

The following example illustrates the If ….. Then.. Else statement.<br />

Example 1.4 Illustrate an example to check for the number of digits in a number and display a message<br />

indicating the number of digits in its within 1000.<br />

• A new Standard EXE project is opened and a TEXT Box and CommandButton is added to the<br />

Form. The following code is entered in the Command 1_Click () procedure.<br />

Private Sub Command 1_Click ( )<br />

If Val (Text1. Text)


Om Edutech Institute Of IT & Applied Technologies <strong>Hamirpur</strong>(H.P)<br />

<strong>Visual</strong> <strong>Basic</strong> 6.0 <strong>Tutorials</strong><br />

Example 1.5<br />

Private Sub Form _Load ( )<br />

Do<br />

X$ =Inputbox $ ("Password Please ?")<br />

Loop Until X$ ="Vanilla Orange"<br />

End Sub<br />

The above example checks for the password set to open the Format runtime. At run time it asks for the<br />

password and until is entered as "Vanilla Orange" the loop remains infinite . Once the correct password is<br />

typed in the input box and click OK , The Form is opened.<br />

The For ….Next Loop Statement<br />

The For …. Next Loop is another way to make loops in <strong>Visual</strong> <strong>Basic</strong>. The following loop counts<br />

from 1 to 50.<br />

for I =1 to 50 step 1<br />

Text1. Text =Str (I)<br />

Next<br />

In order to count from 1 to 50 in steps of 2, the following loop can be used . :<br />

For 1=1 to 50 step 2<br />

Text1. Text =Str (I)<br />

Next<br />

The loop counts as 1,3,5, etc.<br />

Exit For and Exit Do statement<br />

A For ….Next loop can be terminated by an Exit For statement . Consier the following statement block.<br />

For I= to 100<br />

Text1.Text =Str (I)<br />

If 1=50 Then<br />

Exit for<br />

End if<br />

Next<br />

The proceeding code increments the value of I by 1 until it reaches the condition 1 =50. The Exit for<br />

statement is executed and it terminates the For … Next loop. The following statement block –containing<br />

D0… While loop is terminated using Exit do statement.<br />

I=1<br />

Do while I


Om Edutech Institute Of IT & Applied Technologies <strong>Hamirpur</strong>(H.P)<br />

<strong>Visual</strong> <strong>Basic</strong> 6.0 <strong>Tutorials</strong><br />

The ReDim statement can appear only in a procedure , which is an executable statement . The same way of<br />

declaration as used for fixed arrays is used for declaring ReDim statements also.ReDim is an executable<br />

statement. The lower and upper limits for each dimension can also be specified explicitly as in a fixed size<br />

array. An example for this given below.<br />

ReDim FirstArray ( 4 to 12)<br />

Each time on executing the ReDim Statement, the current data stored in the array is lost and the default<br />

value is set. But if we want to change the size of the array without losing the previous data, we have to use<br />

the Preserve keyword with the ReDim Statement. This is shown in the example given below.<br />

ReDim Preserve NewArray (Unbound (FirstArray) +1)<br />

When the Preserve keyword is used, only the upper limit of the last dimension in a multidimensional array<br />

can be changed. No other dimensions or the lower limit of the last dimension can be changed.<br />

Q3 Write a short note on option Explicit.<br />

Ans :<br />

It may be convenient to declare variable implicitly, but it can lead to errors that may not be recognized at run.<br />

Say ,e.g. a variable by name intcount is used implicitly and is assigned to a value. In the next step , the field<br />

is incremented by 1 by the following statement.<br />

Intcount =intcont+1<br />

This calculation will result in intcount yielding a value of 1, as intcont would have been initialized to zero.<br />

This because the intcount variable has been mistyped as intcont in the right hand side of the second<br />

variable. But <strong>Visual</strong> <strong>Basic</strong> does not view this as a mistake and consider it to the new variable and hence<br />

gives a wrong result.<br />

To prevent errors of this nature, we can declare a variable by adding the following statement to<br />

the general declaration section of the Form.<br />

Option Explicit<br />

This forces the user to declare all the variable .The option explicit statement checks in the module for usage<br />

of any undeclared variable and reports an error to the user. The user can thus rectify the error on seeing this<br />

message.<br />

The Option Explicit statement can be explicitly placed in the general declaration section of each<br />

module using the following steps.<br />

Q 4. Write a short note on Procedure and their types.<br />

Ans: Procedure<br />

<strong>Visual</strong> <strong>Basic</strong> program can be broke into smaller logical components called procedures. Procedures are<br />

useful for condensing repeated operations such as the frequently used calculations, text and control<br />

manipulation etc. Following are the benefits of using procedures in programming.<br />

• It is easier to debug a program with procedures, which breaks a program into discrete logical<br />

limits.<br />

• Procedures used in one program can act as building blocks for other programs with slight<br />

modification.<br />

A Procedures can be Sub, Function or Property Procedures.<br />

Sub procedures<br />

A sub procedures can be paced in standard , class and form modules. Each time the procedure is<br />

called, the statements between Sub and End Sub are executed. The syntax for a sub procedure is a<br />

follows.<br />

[ Private | Public ] Sub procedurename [arglist)]<br />

[statements]<br />

End Sub<br />

arglist is list of argument names separated by commas. Each argument acs like a variable in the procedure<br />

. There are two types Sub Procedures – general procedures and even procedures.<br />

Event Procedures<br />

An event procedure is a procedure blook that contains the control's actual name, an underscore (_) and the<br />

event name. The following syntax represents –general procedures and event procedure for a Form_Load<br />

event.<br />

Private Sub Form_Load ( )<br />

.. Statement Block ..<br />

End Sub<br />

Q 5 Write down the names of different controls and their purpose.<br />

Ans: Toolbar is contains a set of controls that are used to place in a form at design time thereby creating<br />

the user interface area. Additional control can be included int eh toolbox by using the Components menu<br />

item on the Project menu. A Toolbox is represented in .<br />

• The pointer helps to move and resize the control and Forms.<br />

• Label displays a text that the user can not modify or interact with.<br />

Created By:- Ajay Verma


Om Edutech Institute Of IT & Applied Technologies <strong>Hamirpur</strong>(H.P)<br />

<strong>Visual</strong> <strong>Basic</strong> 6.0 <strong>Tutorials</strong><br />

• Frame control serves as a visual and functional container for controls.<br />

• Check Box displays a True/False or Yes/No option.<br />

• Textbox is a control used to display message and enter text.<br />

• The List Box displays a list of items from which a user can select one.<br />

• Combo Box contains a Textbox and List Box. This allows the user to select an item from the<br />

dropdown List Box or to type a selection in the Textbox.<br />

• HScroll Bar and Scrollbar controls allow the user to select a value within the specified range of<br />

values.<br />

• Timer control executes timer events at specified intervals of time.<br />

• DirListBox allows the user to select directories and paths, which are displayed .<br />

• Shape control adds a shape (rectangle, square or circle) to a Form.<br />

• Image control is used to display icon, bitmaps , metafiles, etc.<br />

• OLE controls used to link or embed an object , display and manipulate data from other Windows<br />

based applications.<br />

• PictureBox displays icons/ bitmaps and metafiles. It displays text or acts as a visual container for<br />

other control.<br />

• CommanButton carries out the specified action when the user choose it.<br />

• The OptionButton control which is part of an option group allows the user to select one option even<br />

if it displays multiple choices.<br />

• The DriveListBos displays the valid disk drives and allows the user to select one of them.<br />

• The FileListBox displays a set of files from which a user can select the desired one.<br />

• Line control draws a straight line to the Form.<br />

• Data control enables the user to connect to an existing database and displays information from it.<br />

Q 6. Differentiate between Properties, Methods and events.<br />

Ans : All the control in the Toolbox except the Pointer are objects in <strong>Visual</strong> <strong>Basic</strong>. These objects have<br />

associated properties , For example , a flower is loaded with certain color, shape and fragrance. Similarly,<br />

programming objects are loaded with properties.<br />

A property is a named attribute of a programming object. Properties define the characteristic of an<br />

object such as size, color, etc. or sometimes the way in which it behaves. For example , a Textbox accepts<br />

properties such as Enabled, Font, Multi Line , Text, Visible , Width , etc. These are discussed below:<br />

• Enabled property allows the Textbox to be enabled or disabled at run time depending on the<br />

condition set to True or False.<br />

• Font property sets a particular allows the Textbox.<br />

• Multi Line property allows the Textbox to accept the display multiple lines at run time.<br />

• Text property of the Textbox control sets a particular text in the control.<br />

• Visible property is used to hide the object at run time.<br />

• Width property sets the Textbox to the desired width at design time.<br />

The properties that are discussed above are design time properties that can be set at the design<br />

time by selection the Properties widows . But certain properties can not be set at design time.<br />

A method is an action that can be performed on objects. For example, a cat is an object. Its<br />

properties might include long white hair, blue eyes, three pounds weight, etc. A complete definition of<br />

cat must not only encompass on its looks, but should also include a complete itemization of its<br />

activities. Therefore, a cat's method might be move, jump, play, breathe, etc.<br />

Similarly, in object-oriented programming, a method is a connected or built-in procedure, a block of code<br />

that can be invoked to impart some action on a particular object. A method requires an object to provide<br />

them with a context. For example, the word Move has no meaning in <strong>Visual</strong> <strong>Basic</strong>, but the following<br />

statement, performs a very precise action.<br />

Text1. Move 700, 400<br />

The textbox control has other associated methods such as Refresh , SetFocus, ect.<br />

• The Refresh method enforces a complete repaint of the control or a Form. For example, Text1.<br />

Refresh refreshes the Text Box.<br />

• The SetFocus method moves the focus to the control .For example , Tex1. SetFocus sets the<br />

focus to TextBox control Text1.<br />

Q 7 Explain modules and its various types in detail.<br />

Ans. Module is a block of code that performs a specific task and is complete in itself. Modules can be defined<br />

as collection of code that performs a specific task. This code is hidden from rest of the coding on the form.<br />

There are three types of modules in VB.<br />

1. Form Module<br />

2. Standard Module<br />

3. Class Module<br />

Created By:- Ajay Verma


Om Edutech Institute Of IT & Applied Technologies <strong>Hamirpur</strong>(H.P)<br />

<strong>Visual</strong> <strong>Basic</strong> 6.0 <strong>Tutorials</strong><br />

1. Form Module: The form that you see on the screen is representation of the properties that define its<br />

appearance. For each form in an application, there is a related form module that contains its code and the<br />

form module is created in the file with extension .frm.<br />

Each form module contains event procedures which is section of code to response<br />

to specific code. Forms can contain controls & for each control on the form, there is corresponding set of<br />

event procedures in the form module. Form module can contain sub procedure, event procedures and<br />

function procedures. E.g. Form_load() is a event procedure written for each form on the project if needed and<br />

responds when the form is loaded.<br />

2. Code Module/Standard Module: When larger projects are built in VB, then developer wants to reuse the<br />

code as much as possible. For this reason procedures and functions are stored in separate modules rather<br />

than attaching them to forms.<br />

A standard or code module is set of code that you want to be accessible everywhere in the project. Standard<br />

module has no visual components & is useful for reusing the code. So a module or standard module has a<br />

global scope. Code modules are maintained in a separate folder in project explorer window and these files are<br />

stored with .bas extension on hard disk.<br />

3. Class Module: Class module is used to create objects that can be called from procedures within your<br />

application classes. Standard module contains only code & a class module contains both code & data.<br />

Standard module can never have more than one copy but class module data exists separately for each<br />

instance of the class. Class module helps VB to be an object-oriented language. For each class module you<br />

have to create an object of that class.<br />

The data in a standard module has a program scope i.e. it exists for the life of your program while class<br />

module data for each instance of a class exists only for the lifetime of object.<br />

Q 8 Explain Procedures and its various types in detail.<br />

Ans. Procedure: You can simplify the programming tasks by breaking programs into smaller logical<br />

components & these components are called procedures. Procedures are useful for shared and repetitive<br />

tasks. Procedures can be categorized into two parts<br />

1. Event Procedure<br />

2. General Procedure: These are further classified as sub procedure and function procedure.<br />

1. Event Procedure: All the VB objects have various events e.g. clicking a command button is an event & for<br />

each event there can be specific action to be taken. Every time an action is taken, event procedure is fired.<br />

Event procedure is lines of code that tells VB how to respond to a particular event.<br />

2. General Procedure: Event procedure are core of VB programming but if event procedure are long then it<br />

can be broken down into smaller logical units and are called general procedure. There are two types of<br />

general procedures<br />

(i) Sub Procedure: It is a helper program that is used as needed. Sub Procedures are generalizations<br />

of the event procedures. Unlike functions, which normally return values procedures simply do the things.<br />

The idea is that sub procedure are tool which you can choose if you just want to<br />

write a block of code that does something, much as event procedure does something. Sub procedures can be<br />

without parameters or it can have parameters. These can be called with or without the help of call statement.<br />

With call Statement, parenthesis are required while calling the procedure otherwise parenthesis are not<br />

required.<br />

(ii) Function Procedure: Functions are also block of code just like procedures but they can return<br />

values. There are many built in functions and functions defined by the user are called user-defined functions.<br />

We can call a function anywhere in the project if it is declared Public.<br />

Functions can be of following types:<br />

1. Functions with no arguments and with no return type.<br />

2. Functions with arguments and with no return type.<br />

3. Functions with no arguments and with return type.<br />

4. Functions with arguments and with return type.<br />

Q 9 What is control? Can we create our own control in visual <strong>Basic</strong>?<br />

Ans. A control is which we place on the form to create a user interface. Examples of controls are command<br />

button, textbox control, label, picture box etc. We can add more controls by right clicking on the toolbox and<br />

selecting components from pop up menu. All the controls can be accessed from the toolbox. Nearly every<br />

control has its own properties & methods. We can set the properties at design time and through coding. We<br />

can make controls response to happening of events. For example: change method of textbox responds to<br />

the code written in change method whenever the text in the textbox changes.<br />

We can create our own controls in visual <strong>Basic</strong> & these are called ActiveX controls. User<br />

can design their own controls or can extend the properties of existing controls. For example: you can design<br />

a textbox control that accepts only numeric data.<br />

Q.10) Explain types of dialog boxes.<br />

Created By:- Ajay Verma


Om Edutech Institute Of IT & Applied Technologies <strong>Hamirpur</strong>(H.P)<br />

<strong>Visual</strong> <strong>Basic</strong> 6.0 <strong>Tutorials</strong><br />

Ans. There are three kinds of dialog boxes.<br />

4) Modal dialog box<br />

4) Modeless dialog box<br />

4) System modal dialog box<br />

Modal dialog box: - Model dialog boxes can be called as application modal dialog box. This dialog box insists<br />

the user to respond to them, before continuing in the same application. A modal dialog box while in action<br />

stops running your code until it is close or hidden. The show method of form uses VbModal style to load the<br />

form as a modal dialog box.e.g.<br />

Form1. Show VbModal.<br />

Modeless dialog box: - Modeless dialog box do not need to be closed to loose their focus. They are just like<br />

any other form in your application and loose their focus as soon as you click some other window outside the<br />

application. A form is by default loaded in this state if no arguments are supplied to show method.<br />

System modal dialog box: - A system model dialog box restricts the user from continuing work on the<br />

system unless it gets unloaded. Screen saver with passwords is example of system modal dialog box. The<br />

show method doesn’t have this style but in order to call a default message box in a system modal style, we<br />

can use the following syntax.<br />

MsgBox “Message string “, VbOkOnly + VbSystemModel.<br />

Q 11 Write down the various types of ActiveX controls.<br />

Ans :<br />

<strong>Visual</strong> <strong>Basic</strong> offers the user three different types of control .The techniques for authoring all ActiveX control<br />

are the same. The type we need to build however depends on the requirement and the amount of<br />

functionality that is required to be included in our control. The different type of ActiveX control. The<br />

different types of ActiveX controls offered by <strong>Visual</strong> basic are as follows.<br />

• User drawn control<br />

• Enhancement to existing <strong>Visual</strong> <strong>Basic</strong> control<br />

• New controls built with constituent controls<br />

User Drawn Control<br />

These controls are developed from scratch . The user is responsible for designing the control's interface and<br />

is in control of its appearance and interface. These implementation of these controls is very difficult as<br />

every bit of functionality starting from the control's interface to its appearance has to be written by the<br />

developers/users. They also are the most flexible ones as the user does not have to put up with the<br />

limitations of other controls.<br />

Existing <strong>Visual</strong> <strong>Basic</strong> Control<br />

The simplest of custom ActiveX control is one that is based on an existing control. The user can keep most<br />

or all of the original control's functionality and then add custom members.<br />

For example, when the style property of the Combo Box is to 0 (Dropdown) or 1 (Simple Combo), the<br />

user can enter a new field value in the edit box of the control, but the new entry is not appended to the<br />

list of available choices. This can be enhanced by enrapturing the Enter key. When the user presses<br />

Enter, add the entry in the Edit box to the list of options. This can result in the development of a new<br />

control, say Enhanced Combo.<br />

Constituent Control<br />

In cases where most of the functionality we want to include in our custom control already exits, a new<br />

control can be designed that include existing control. The control that form part of the newly developed<br />

custom control are called constituent control.<br />

Q 12.Differentiate between ActiveX EXE and Active X DLL<br />

ANS: Servers can be implemented as ActiveX DLL or Active X EXE components. The difference lies in how<br />

the server is executed. An ActiveX DLL is an in-process server. The DLL is loaded in the same address<br />

space as the client executable that calls the server and it runs on the same thread as the client. At any<br />

given moment however, the client application or the DLL is running. The merits of DLL are that they are<br />

faster, they become part of the application that uses them.<br />

An ActiveX EXE otherwise called as an out-of-process server, as the name indicates runs as a<br />

separate process. When a client application creates an object provided by an EXE server for the first time,<br />

the server starts running as a separate process. If another client application creates the same object, the<br />

running EXE server provides this object . In other words, a single EXE server can service multiple clients.<br />

Out-of-process servers seem to be more efficient in terms of resource allocation , but exchanging<br />

information between servers is a slow process.<br />

We will be working with a client server model. Here the application is client , which sends requests<br />

and the ActiveX Component is the server, which services the request. Though ActiveX DLLs run within the<br />

same application as the client , they are considered as to be servers.<br />

Difference between ActiveX EXE and ActiveX Component<br />

Created By:- Ajay Verma


Om Edutech Institute Of IT & Applied Technologies <strong>Hamirpur</strong>(H.P)<br />

<strong>Visual</strong> <strong>Basic</strong> 6.0 <strong>Tutorials</strong><br />

The distinction between server types results in difference in testing the components. An ActiveX can be<br />

tested by adding a test project to the ActiveX DLL project. Since both the server component and the test<br />

application run in the same process, we don't need two difference executables.<br />

Q 13 : DEFINE THE FOLLOWING<br />

ANS : <strong>Visual</strong> basic provides a variety of options to access remoter Client\Server database. They are<br />

• Data Access Objects (DAO) It communicates with data sources through the JET database<br />

engine.<br />

• Data Control : It binds data-war –aware to Microsoft Access and other ODBC data sources.<br />

• ODBC Direct It allows accessing of ODBC data sources through the RDO with DAO object,<br />

bypassing the JET database engine.<br />

• Remote Data Object : (RDO): It provides a framework for using code to create and manipulate<br />

components of a remote ODBC database system.<br />

• Remote Data Control (RDC) It binds the controls to an ODBC remote database .<br />

• Open Database Connectivity (ODBC) : This is an API call interface to the open Data<br />

Connectivity libraries and drivers to provide data access to Oracle and other databases that<br />

provide data access to Oracle and other databases that provide an ODBC driver.<br />

• <strong>Visual</strong> <strong>Basic</strong> Library for SQL Server (VBSQL) : It is an implementation of the DB library API<br />

specifically designed to provide access to an SQL server through a visual <strong>Basic</strong> Application.<br />

• Active Data Object (ADO) : This is a programming model that eliminates the need to choose<br />

from among DAO and RDO and all other data access methods. It is designed to provide a<br />

command bridge between different database , file system and e-mail servers.<br />

Q 14 Explain the scope the variables.<br />

Ans :A variable is scoped to a procedure or object determines which parts of the code in our application are<br />

aware of the variable's existence .A variable is declared in general declaration section of Form and<br />

hence is available to all the procedures. Local variable are recognized only in the procedure in which<br />

they are declared. They can be declared with Dim and Static keywords. If we want a variable to be<br />

available to all of the procedure s in an application, a variable is declared with broader scope.<br />

Local Variables<br />

A local variable is one that is declared inside a production. This variable is only available to the code<br />

inside the procedure and can be declared using the Dim statement as given below.<br />

Dim int Temp As integer<br />

The local variable exits as long as the procedure in which they are declared, is executing. Once a<br />

procedure is executed, the values of its<br />

local variable are lost and the memory used by these variable is freed and can be reclaimed. Variables that<br />

are declared with keyword Dim exit only as long as the procedure is being executed.<br />

Static Variable<br />

Static variable are not re-initialized each time <strong>Visual</strong> <strong>Basic</strong> invokes a procedure and thus retains or<br />

preserves value even when a procedure ends. In case we need to keep track of the number of times a<br />

Command button in an application in clicked, a static counter variable has to be declared. These static<br />

variable are also ideal for making control alternately visible or invisible. A static variable is declared as<br />

given below.<br />

Static inter Permanent as Integer<br />

Variable have a life time in addition to scope . The values in modules level and public variables are<br />

preserved for the lifetime.<br />

Q 15.Explain briefly about COM and DCOM.<br />

Ans : Component Object Model<br />

Component Object model (COM) is the basis for all OCX controls. COM is a specification. It doesn’t tell the<br />

user how to implement a control ; rather it concentrates the way in which two process communicate with<br />

each other and defines some standard interface for them to communicate.COM allows software components<br />

to communicate with each other. It is a binary standard that allows any two components to communicate<br />

regardless of the language the components are written in. The only way to access and interact with a COM<br />

object is through interfaces.<br />

Distributed Component Object Model<br />

Distributed Component is nothing but COM a network. It allows information exchange over the internet , the<br />

local intranet or any other network. While COM is the basis for OCX controls , DCOM is the basis for ActiveX<br />

controls – as ActiveX itself is nothing but internet enable OCX.<br />

Q16 Write a code in <strong>Visual</strong> <strong>Basic</strong> to Serach a Record in Database.<br />

Ans Object Properties Setting<br />

Data Name DatabaseName c:\vb\student.mbd<br />

Recordsource Student<br />

Created By:- Ajay Verma


Om Edutech Institute Of IT & Applied Technologies <strong>Hamirpur</strong>(H.P)<br />

<strong>Visual</strong> <strong>Basic</strong> 6.0 <strong>Tutorials</strong><br />

Private Sub Command1_click ()<br />

Data1.Record.FindFirst (“Sname=’” &DBcontrol.text & “ ’ ”)<br />

Text1.Text=Data1.Recordset.fields(5)<br />

Data1.Refresh<br />

End Sub<br />

Q17 Write a code in <strong>Visual</strong> <strong>Basic</strong> to update a record in Database.<br />

Ans:<br />

Object Properties Setting<br />

Command button 1 Name Command 1<br />

Caption Modify<br />

Command button 2 Name Command 2<br />

Caption Update<br />

Command button 3 Caption Exit<br />

Data Name Data1<br />

DatabaseName c:\vb\Supplier.mbd<br />

Record source Supplier<br />

The following code entered in the Command button1 click<br />

Private Sub Command1_click()<br />

Msgbox “You are now modify the Current Record”<br />

Data1.Recordset.Edit<br />

Text1.Enable= False<br />

Text2.Enable=False<br />

End Sub<br />

The following code entered in the Command buton2 click<br />

Private sub Command2_click()<br />

Data1.Recordset (2) = Text3.Text<br />

Data1.Recordset (3) = Val (Text4.Text)<br />

Data1.Recordset.Update<br />

Msgbox “Record Update in file”<br />

Data1.refresh<br />

End Sub<br />

Q 18. Write a note on POP-UP menu.<br />

Ans: a popup menu is floating menu that is display over a form independent of the menu bar. Pop<br />

Created By:- Ajay Verma


Om Edutech Institute Of IT & Applied Technologies <strong>Hamirpur</strong>(H.P)<br />

<strong>Visual</strong> <strong>Basic</strong> 6.0 <strong>Tutorials</strong><br />

Up menu are also called context menu, because the items displayed in the pop up menu depend on where<br />

the pointer is located when the right mouse button is clicked.<br />

Any menu can be display as a pop up menu at run time provided it has menu item.<br />

Private sub_form_MouseDown (Button As Integer, Shift As integer, X As Single ,Y As Single)<br />

If button =2 then<br />

PopUpMenu mnuColors<br />

End if<br />

End Sub<br />

Q 19. Write a note on Dragging and Dropping.<br />

Ans: Dragging is the process of clicking the mouse button in a control and moving the mouse while holding<br />

down the mouse button. The action of releasing the mouse button after the dragging is called<br />

Dropping.<br />

DragMode property enable automatic or manual dragging of a control<br />

DragDrop event is recognized when control is dropped onto object<br />

Drag method starts or stops manual dragging.<br />

Q 20.Compare conventional and Object Oriented Programming.<br />

Ans<br />

Conventional Programming using high language such as COBOL , FORTRAN commonly know as<br />

procedure oriented programming.<br />

1.Large programs are divided into smaller programs knows as functions.<br />

2.Most of the function shares global data.<br />

3.Data moves openly around the system from function to function.<br />

4.Funtions transform data from one form to another.<br />

5.Employs top down approach in program design.<br />

Objecting Oriented Programming<br />

1.Programs are divided into what are known as objects.<br />

2.Data Structure are design such that they characterized the objects.<br />

3.Functions that operate on the data of an object are tied together in the data structure.<br />

4.Data is hidden and cannot be accessed by external functions.<br />

5.Objects may communicate with each other through functions.<br />

6 Follows bottom up approach in program design.<br />

Q 21 What is visual basic? From which language is it derived?<br />

Ans. <strong>Visual</strong> basic is object-oriented language, which provides graphical user interface just like Microsoft<br />

windows. <strong>Visual</strong> basic provides integrated development environment. <strong>Visual</strong> basic provides three editions<br />

i.e. Learning edition, professional edition & enterprise edition. <strong>Visual</strong> basic integrated development<br />

environment provides editor, designing, compiler & debugging capabilities. <strong>Visual</strong> basic provides Internet<br />

features, object linking and embedding & various other capabilities to develop robust windows applications.<br />

<strong>Visual</strong> basic applications provides excellent user interface & through VB developer is<br />

capable of connecting to various database. <strong>Visual</strong> basic is derived from language basic.<br />

Q 22) What is control? Can we create our own control in visual <strong>Basic</strong>?<br />

Ans. A control is which we place on the form to create a user interface. Examples of controls are command<br />

button, textbox control, label, picture box etc. We can add more controls by right clicking on the toolbox and<br />

selecting components from pop up menu. All the controls can be accessed from the toolbox. Nearly every<br />

control has its own properties & methods. We can set the properties at design time and through coding. We<br />

can make controls response to happening of events. For example: change method of textbox responds to<br />

the code written in change method whenever the text in the textbox changes.<br />

We can create our own controls in visual <strong>Basic</strong> & these are called ActiveX controls. User<br />

can design their own controls or can extend the properties of existing controls. For example: you can design<br />

a textbox control that accepts only numeric data.<br />

Q 23 Write a short note on common dialog box.<br />

Ans. A common work in most of the applications is to prompt user for filenames, selecting files to open,<br />

saving the file on hard disk, font names & sizes or colors to be used in applications. Common dialog control<br />

is peculiar & provides services to the application but is not displayed on the form at runtime. Common<br />

dialogs control provides built-in windows dialog boxes.<br />

2. Open - File open common dialog box lets user select a file to open.<br />

2. Save As - File save common dialog box lets users select or specify a file name in which current<br />

document will be saved.<br />

2. Color - The color dialog box lets user select colors or specify custom colors.<br />

2. Font - Font common dialog box lets user select font &style to be applied to current text selection.<br />

2. Print - Print common dialog box lets user select and set up a printer.<br />

2. Help- help common dialog box displays help topics.<br />

Q 24 Explain immediate window.<br />

Created By:- Ajay Verma


Om Edutech Institute Of IT & Applied Technologies <strong>Hamirpur</strong>(H.P)<br />

<strong>Visual</strong> <strong>Basic</strong> 6.0 <strong>Tutorials</strong><br />

Ans. When an application of VB is interrupted by pressing Ctrl+Break, a window is shown at the bottom of<br />

the screen called immediate window. When <strong>Visual</strong> basic commands are issued in this window, they execute<br />

immediately with the help of immediate window, you can see the control flow of the program & can work out<br />

which events are fired at what time. It is debugging aid & when an application is running, you can stop it and<br />

use the immediate window to examine or change the values the applications variables. You can step into the<br />

code of the application while it is executing, can change the value of the variables & even insert statements<br />

in the code & then continue the execution of an application.<br />

Immediate window can act as a calculator. For example if you enter following statement in<br />

immediate window.<br />

Print 1888/999 & press enter, the following result is displayed<br />

1.889889889<br />

Q 25 Explain the following.<br />

3. Rnd function.<br />

3. Date function.<br />

3. Time function.<br />

3. Strcomp function.<br />

3. Instr function.<br />

Ans. Rnd function: - Rnd function generates random numbers that doesn’t follow any pattern. For example-<br />

If you write the following code in the form click event.<br />

Private sub form – Click ()<br />

Dim I as integer<br />

For I = 1 to 5<br />

Print Rnd<br />

Next I<br />

End sub.<br />

It will generate five random numbers between 0 & 1.<br />

Date function: - Date function displays the system date eg.<br />

Text 1. Text = Date<br />

It will display the system date in the textbox.<br />

Time function: - Time functions displays the current system time. eg<br />

Text1. Text=Time<br />

It will display system time in the text box.<br />

Strcomp function: - This function can be used to compare strings. Functions returns a value, such as for<br />

example<br />

If you set X=strcomp (A $, B $), then value of x is –1 if A$ is less then B$, 0 if A$ equals B$, 1 if<br />

A$ is greater than B$ and x is NILL if one is empty.<br />

Instr() function :- Instr function tell you whether a string is part of another string and tells you the position<br />

from where that string starts. The syntax is<br />

Instr [string1, string2, compare]<br />

Q 26 Write a short note on RichTextBox control.<br />

Ans. Rich textbox control full-fledged word processor, it provides all the functionality of a textbox control and<br />

gives you capability to mix different fonts, sizes and attributes. You can place images in your text on a rich<br />

textbox control.<br />

Main property of rich textbox control is Text property & contains the<br />

Text currently displayed by the control. You can use RichTextBox control to specify the text’s formatting<br />

including paragraph indentation, font, font size & style etc. The control provides simple properties that turn the<br />

selected text to bold, italics & underline & so on. The two important methods of Rich textbox control are save<br />

file that saves the contents of control on the disk and load file that loads the contents of file from the disk.<br />

Q 27) Describe form life cycle.<br />

Ans. Form life cycle can be describe as when a form loads until the form is unloaded. When a form is loaded<br />

the events fired are referred to as Birth Events such as Initialize Event, Load event Resize Event, Activate<br />

Event. To watch the interaction of the user with the form various events are fired such as mouse move Event,<br />

click event, double click event etc. When the form is unloaded its shutdown events are fired such as<br />

QueryUnload Event, unload event, terminate event. All these events can be tracked through the immediate<br />

window. We can display a message each time an event is fired.<br />

Q 28 Write a short note on masked edit controls.<br />

Ans. Microsoft masked edit controls is used for input validations in a text box. It looks like an ordinary text box.<br />

You can restrict the characters entered without having to write code in the key events. Most important property<br />

is mask property. This property controls what the user can enter.<br />

Created By:- Ajay Verma


Om Edutech Institute Of IT & Applied Technologies <strong>Hamirpur</strong>(H.P)<br />

<strong>Visual</strong> <strong>Basic</strong> 6.0 <strong>Tutorials</strong><br />

The event dealing with input to Masked edit box is ValidationError event. This event is fired whenever<br />

user tries to enter invalid character.<br />

Q29. What is recursion? Explain with suitable example.<br />

Ans. Recursion can be described as a procedure in which a function or procedure calls itself. Code written in a<br />

function is extended sequentially but when a function calls itself then the same code is executed for each call<br />

to function. In recursion function calls, itself again & again.<br />

E.g. If we want to calculate factorial with the help of recursion then we can write the following<br />

function.<br />

Private Function rec (x as integer)<br />

If x = 1 then<br />

Rec= 1.<br />

Else<br />

F = rec (x – 1)<br />

Rec =f<br />

End If.<br />

Q 30) Write a short note on status bar control.<br />

Ans. Status bars are implemented in visual basic via the status bar control and it runs along the bottom of an<br />

application window and provides the information about the current status of the application. Status bar is a<br />

good place to put information that helps users to keep track of program options they selected.<br />

Status bar control is not an intrinsic control & can be added from components dialog box named<br />

Microsoft Windows Common Control 6.0. status bar is always added at the bottom of the form & you should<br />

set the form’s border style to fixed single so that user cannot change the size of the form.<br />

Q 31) What do you understand by OLE?<br />

Ans. OLE is object linking & embedding. With the help of OLE we can add other objects in your visual basic<br />

application .OLE control is a part of visual basic toolbox. Through OLE control you can insert an object from<br />

one application into another application. The inserted object is copy of original object. For example, you can<br />

embed a range of cells from an excel worksheet in a word document. OLE container control, which allows you<br />

to insert objects from other applications into your program. You can place only one object in the container<br />

control at a time, but there can be multiple OLE container control on a single form. You can embed word<br />

documents, sounds, bitmaps and excel spreadsheets in your VB applications. OLE container control hides all<br />

the complications of OLE from the user & you can build OLE-capable applications.<br />

32) Explain in the term DLL?<br />

Ans. The term DLL’s full form is Dynamic link Library. It is a COM based object, which is not executable by<br />

itself & is intended to be used by another application. Every windows application that is executed must reside<br />

in memory. Active DLLs are loaded into the same process as the application that uses the Active XDLL. This<br />

is why ActiveX DLL are often called in the process components.<br />

To create ActiveX DLL we open an ActiveX DLL project. By default ActiveX DLL has one class<br />

module and its extension is .dll. We create a stand-alone file that can be used independently when a DLL is<br />

created, we can save it anywhere on the disk. Once we have created the DLL we can use it in another<br />

applications by adding a reference to it. We can test the DLL by opening standard EXE and adding a<br />

reference to the DLL by using reference dialog box.<br />

Q 33) Explain the terms passing by value & passing by reference.<br />

Ans. When you call a function or procedure, there are two ways to pass an argument.<br />

4. Passing by reference.<br />

4. Passing by value.<br />

When you pass an argument variable by reference, any changes to the corresponding parameter inside the<br />

procedure will change the value of the<br />

Original argument when the function or procedure finishes, when you pass an argument by value, then<br />

original variable retains the original value after the procedure finishes. For example<br />

Sub Triple (Num as Integer)<br />

Num = 3 * Num.<br />

Print “ I am in the procedure (pass by reference)”<br />

End sub.<br />

Sub triple (BY Val Num as integer)<br />

Num = 3*Num.<br />

Print “ I am in the procedure (Pass by value)”<br />

End sub.<br />

In visual <strong>Basic</strong>, passing an argument by reference is default. If we have to pass an argument by<br />

value then we have to specifically mention the keyboard ‘By Val’.<br />

Q 34) What do you understand by term property pages?<br />

Created By:- Ajay Verma


Om Edutech Institute Of IT & Applied Technologies <strong>Hamirpur</strong>(H.P)<br />

<strong>Visual</strong> <strong>Basic</strong> 6.0 <strong>Tutorials</strong><br />

Ans. Active controls can have property pages. Property pages are similar to the properties windows and they<br />

allow the developer to set the control’s properties. Properly pages are better and have more flexible user<br />

interface.<br />

The properties you set through the properties windows apply to the entire control and property pages<br />

of the control contain several pages on which related properties are grouped. Property pages of a control can<br />

be displayed by Right clicking the control & selecting properties from the pop-up menu .We can design the<br />

property pages through the property page wizard.<br />

Q 35) How an array can be passed to a function?<br />

Ans. An array can be passed to a function in two ways.<br />

3. By reference or by value elements when the function supports one single argument only.<br />

E.g.<br />

Dim A(5) as integer<br />

For x = 0 to 4<br />

Print Sqrt ((x))<br />

Next<br />

3. By reference when the function supports an array argument<br />

Example.<br />

Private function Fun (y () as integer) As Integer<br />

Dim Z(3) as integer<br />

For I = 0 to 2<br />

Z (I) = Y (I) + Y (I)<br />

Next I<br />

Fun = Z<br />

End function<br />

Q 36) What do you understand by file system controls?<br />

Ans. File system controls in visual basic allow users to select a new drive, to see the hierarchical directory<br />

structure of disk or to see the names of the files in a given directory. For these controls you also have to write<br />

code to take full advantage of these controls. There are three main controls named DirList Box, DriveList Box<br />

& FileListBox. Dirlistbox displays the directories in the drives in the computers and any other drive attached to<br />

the computer. File list box displays the files in the current directory .we can attach these controls with each<br />

other so that when a drive is select all its directories should be displayed in the DirListbox and when a<br />

directory is selected its files should be displayed in the file list box. File system controls let you to control the<br />

file system of the computer.<br />

Q 37) What do you understand by transactions?<br />

Ans. Transaction is a database terminology and it is sequence of alterations made to a table in the database.<br />

Transactions can be simply stated as any changes made to the database tables. In visual basic we can make<br />

transactions with database with the help of various controls like DAO, ADO etc. We can create record sets in<br />

VB with which we can manipulate the database tables. <strong>Visual</strong> basic can store all the transactions that it is<br />

making so that if there is any need we can undo them. There are three statements in VB namely BeginTrans,<br />

CommitTrans, RollBack. BeginTrans makes the log of each & every transaction so that at later stage we can<br />

undo them.<br />

CommitTrans commits the changes to database. RollBack roll backs or undo the changes made in the<br />

database.<br />

Q 38) Discuss timer control with suitable example.<br />

Ans. Time control is used to fire on event at specified internals .The code you want to execute is place in the<br />

timer event of timer control. This control has no methods and only one event called timer event. And has<br />

seven properties. This control is invisible at run time. When a timer control is placed on form its Enabled<br />

property is by default true. Whenever this property is set to true the timer control’s timer event is fired at<br />

regular intervals as specified. The unit of measurement is milliseconds. For example, following code will print<br />

how many times the timer has been fired Private Sub Timer1_Timer()<br />

Static counter as long<br />

Counter = Counter +1<br />

Me. caption = “ The timer has been fired “ & str (counter)& “times! “<br />

End Sub<br />

Q 39 What is DAO? Explain .<br />

Ans. DAO is data access object & it is a structure of objects for accessing database through your code. We<br />

can access the database with the help of a data control & DAO provides all the functionally of the data control.<br />

DAO object model has 17 types of objects like database, recordsets, fields etc. Data access<br />

object is implemented through an active control called the data control. We can use DAO by writing a single<br />

line of code. When it is used with other data controls like DbList, DbCombo, DbGrid, it is a very powerful tool.<br />

Information from a database is fetched by the DAO and provided to various controls like Textbox, Dblist etc.<br />

Created By:- Ajay Verma


Om Edutech Institute Of IT & Applied Technologies <strong>Hamirpur</strong>(H.P)<br />

<strong>Visual</strong> <strong>Basic</strong> 6.0 <strong>Tutorials</strong><br />

DAO accesses database through DbEngine & it is controlled by your application through its object classes,<br />

their methods & properties.<br />

Q 40 What is recordset? Explain.<br />

Ans. Recordsets are objects that represent collections of records from one or more tables .In database<br />

programming, Recordsets are the equivalent of variable in regular programming. Tables of database can’t be<br />

accessed directly. The only way to view or manipulate records is via recordset object. A recordset is similar to<br />

tables in database i.e. it consists of rows & columns and also it can contain data from multiple tables. It is just<br />

like a grid and records in recordset. Recordsets are the result of queries. Recordsets are object variables. It<br />

can store result of queries or an entire table of the database. The contents of the recordset, however, have a<br />

more complicated structure and each cell in this grid can be of a different type. To access the contents of the<br />

recordset, you can use its properties & methods. So a recordset is view of some of the data in the database,<br />

selected from database according to user specified criteria.<br />

Q 41 Write a program in which When you click on add button the new option button is added and<br />

when delete button is clicked option button is deleted and when you click an option button the color<br />

of the picture changes.<br />

Ans. DIM MaxID as integer<br />

Private Sub and Add_Click ()<br />

If MaxID =0 then MaxID =1<br />

If MaxID >8 then Exit Sub<br />

MaxID = MaxID +1<br />

Load optbutton (MaxID)<br />

Opt button (O). Set focus.<br />

Opt button (MaxID). Top = Opt button (MaxID – 1). Top + 400<br />

Opt button (MaxID). Caption = “Option”&MaxID + 1.<br />

End sub<br />

Private Sub delete_Click ()<br />

If MaxID< =1 then exit sub.<br />

Unload opt button (MaxID)<br />

MaxID = MaxID – 1<br />

Opt button (0). Set focus.<br />

End Sub<br />

Private Sub optbutton_Click (index as integer)<br />

Picdisplay. Back color = QB color (Index +1)<br />

End Sub<br />

Q 42) Explain Scrollbar & Slider controls?<br />

Ans. The scrollbar & slider controls allow the user to specify a magnitude by scrolling a selector between its<br />

minimum and maximum values. Sometimes, the user doesn’t know in advance the exact value of the<br />

quantity to specify. The vertical scroll bar that lets the user move up & down along document. The scroll bars<br />

are the prime mechanism to view large image or text that doesn’t fit entirely in a window. While scrolling a<br />

long document horizontally or vertically, the user doesn’t have to bother about line numbers or pixels.<br />

The slider control is similar to scrollbar control but it does not cover a continuous range of<br />

values. The slider control has a fixed number of tick marks, which the developer can label. The user can<br />

place the slider’s indicator to the desired value. Scrollbar is used where continuous value is important and<br />

slider control is used where discrete values are required, for example slow, medium, fast etc. Scrollbar<br />

control is a long stripe with an indicator that lets the user select a value between two ends of the control<br />

scrollbar can be of two types – horizontal & vertical. The basic properties of scrollbar control are Min, Max<br />

and value. Slider control is similar to the scrollbar control but there is no continuity but there is some specific<br />

range e.g. slow, fast and very fast. Slider control is not an intrinsic control of VB and we can add it from<br />

components dialog box by selecting Microsoft common controls 6.0.<br />

Q 43 Write a program to make a text editor with cut and paste facilities.<br />

Ans. Open a standard EXE project. Place a textbox and place four buttons on it. Name the command button<br />

as cmdcut cmdquit, cmdpaste and cmdreset. Name the text box as text editor & add the following code.<br />

DIM store as string<br />

Private Sub cmdcut_click ()<br />

Cuttext=Texteditor.Seltext.<br />

store=Texteditor.Seltext.<br />

Texteditor.Seltext=” “<br />

Cmdpaste.Enabled=true<br />

Texteditor.Set focus.<br />

Created By:- Ajay Verma


End Sub<br />

Om Edutech Institute Of IT & Applied Technologies <strong>Hamirpur</strong>(H.P)<br />

<strong>Visual</strong> <strong>Basic</strong> 6.0 <strong>Tutorials</strong><br />

Private Sub cmdQuit_Click ()<br />

Unload me.<br />

End Sub<br />

Private Sub cmdreset_Click ()<br />

Texteditor. Text=” “<br />

Texteditor. Set focus<br />

End Sub<br />

Private Sub Text editor_Change()<br />

Cmdcut.Enabled=True<br />

Cmdpaste.Enabled=True<br />

Cmdreset.Enabled=True<br />

Private sub cmdpaste_Click()<br />

Texteditor.Seltext=store<br />

Texteditor.Set focus<br />

End Sub<br />

Q 44 Write a program having one command button and on pressing the button it should display<br />

labels & text boxes of Name, age, Roll No, and Address?<br />

Ans.<br />

Private Sub command1_Click()<br />

Dim captions (10) as string<br />

Dim sizes (10) as integer<br />

Caption (1)=”Name”<br />

Caption (2)=”Age”<br />

Caption (3)=”Roll No.”<br />

Caption (4)=”Address”<br />

Size (1)=20<br />

Size (2)=30<br />

Size (3)=15<br />

Size (4)=40<br />

For I=1to 5<br />

Load labels (I)<br />

Load text boxes (I)<br />

Labels (I).Top=labels (I-1). Top+400<br />

Labels (I).Left=labels (0). Left<br />

Text boxes (I).Top=Text boxes (I-1).Top+450<br />

Text boxes (I).Left=Text boxes (0).Left.<br />

Text boxes (I).Width=Sizes (I) * 60<br />

Labels (I).Caption = Caption (I)<br />

Labels (I).Visible = True<br />

Textboxes (I).Visible = True<br />

Next<br />

Q 45 Explain ADO object model in detail?<br />

Ans. ADO is active data object. ADO object model is similar than the DAO model and it can handle more<br />

databases and has more features. ADO model consists of three objects namely.<br />

1.Connection<br />

2.Command<br />

3.Recordset<br />

1.Connection: - It is a top-level object & represents a connection to the data source. We establish a<br />

connection to a data source and issue a command against the connection object to retrieve the desired<br />

records from the database or to update the database.<br />

2.Command: - This object represents a SQL statement or stored procedure that can be processed by the<br />

data source. The command object doesn’t return any results if it updates the database or returns a recordset<br />

with the requested records. To set up a command object, you specify the SQL statement or stored<br />

procedure and its parameters. We can call the execute method to execute the SQL statement or stored<br />

procedure against the data source. One more approach is to create a recordset object, associate a<br />

command object with it and retrieve the desired records.<br />

Created By:- Ajay Verma


Om Edutech Institute Of IT & Applied Technologies <strong>Hamirpur</strong>(H.P)<br />

<strong>Visual</strong> <strong>Basic</strong> 6.0 <strong>Tutorials</strong><br />

3.Recordset: - This object stores the results of the execution of command object in a database. Recordsets<br />

can be created without an explicit connection. To access the fields of a recordset object, we can use field’s<br />

collection.<br />

Q 46 Explain in process & out of process servers?<br />

Ans. A class module is server, or an application that provides its services to client applications. When we<br />

create an object variable to access the properties and methods of a class, we involve an executable file,<br />

which runs in the back round & waits to be contacted. Whenever we set or read a property value or call a<br />

method, this executable file performs some actions and return results to your application. Servers can be<br />

implemented as ActiveX EXE or ActiveX DLL components. The difference is how they are executed.<br />

An ActiveX DLL is called in process server. The DLL is loaded in the same address space<br />

as the executable that calls the server. At any point either the application or the DLL is running. A DLL is<br />

faster and becomes part of the application that uses it.<br />

An ActiveX EXE is an out-of-process server and runs as separate process. When an<br />

application creates an object provided by an EXE the server starts running as a separate process. If another<br />

application creates a same object, the new object is provided by the already running EXE. So a single EXE<br />

provides services to multiple applications. Example of out-of-process server is Excel. You can run two or<br />

more applications that requests services of excel and it will be serviced by a single instance of excel.<br />

Q 47 Explain ADO data control.<br />

Ans. Earlier there were DAO & RDO controls which were used to access the databases but these were not<br />

sufficient for more advanced databases like Oracle, SQLServer etc. One of the new controls added to <strong>Visual</strong><br />

<strong>Basic</strong> is Active Data Control or ADO data Control. With ADO data control, We can connect to more databases<br />

of different types.<br />

The simplest way to use ADO in your projects is to add ADO in the project & use it<br />

on the form just like we use DAO. We can add ADO data control from the components. From the project<br />

menu, select components & from the components check Microsoft ADO control 6.0 (OLEDB) option. ADO<br />

control will be displayed in the toolbox of VB.<br />

ADO data control has various properties. Place the control on the form & right click<br />

it to open property pages of ADO control. We now have to specify the name of the data source i.e. name of<br />

the database that ADO data control will connect. There are three types of data sources:<br />

1. File Data source: A database file that all user on the machine can access.<br />

2. User Data source: A database file that a specified user can access.<br />

3. System Data source: A database file that any user that can log on to the machine can access.<br />

When ADO data control is placed & data source is specified we can bind various<br />

other controls like textboxes, list boxes, comboboxes etc. to ADO data control by specifying data source and<br />

data member properties. This is why ADO data control is very effective tool for connecting to databases.<br />

Q 48 What are ActiveX Controls define it and explain any two applications of ActiveX controls.<br />

Ans. ActiveX is a set of reusable components that can be created and utilized by several applications. ActiveX<br />

uses the internet technology to assist in creating compact and reusable applications that can be deployed via<br />

internet or a corporate intranet.<br />

ActiveX provides a familiar client server infrastructure to run your applications. Controls like<br />

coolbar, flatscrollbar, imageCombo are ActiveX controls. ActiveX control can also be used in other ActiveX<br />

compliant programs. These can be embedded and distributed through HTML web pages.<br />

Image List Control: While working with toolbar & coolbar each button is assigned an image and image list<br />

works behind the scene. It is not visible at run time and gives a way to store a group of images in a single<br />

place. The key to work with an Image List control is ListImage object and ListImages collection. The<br />

ListImages collection specifies the images stored. The main properties of Image List control are its custom<br />

properties and are shown as dialog box. You can set pictures in the ImageList control at design time and use<br />

their index to refer them. The Image tab on this dialog box gives a convenient way to add images at design<br />

time.<br />

To use image from imagelist control we can write<br />

Set Picture1.picture=ImageList1.ListImage(1).Picture<br />

Toolbar Control: It is one of the most important tools for providing an easy interface to the users. The toolbar<br />

control provides easy access to options available in your application. To add design time properties to the<br />

controls select its custom properties from the property windows.<br />

A toolbar control contains a collection of Buttons objects used to create toolbar. A<br />

toolbar contains buttons that correspond to items in an application’s menu, providing a graphical interface for<br />

the user to access an application’s most frequently used functions and operations. You can even add an<br />

Image in a button and Image list control is required on the same form, to add images in the toolbar at design<br />

time. You can add buttons at design time in the toolbar using its property pages. The custom property page<br />

has three tabs, General, Buttons and Picture. In the buttons tab you can add more buttons to the toolbar.<br />

Q49 Write about salient features of VB.<br />

Ans. Some features of VB are<br />

Created By:- Ajay Verma


Om Edutech Institute Of IT & Applied Technologies <strong>Hamirpur</strong>(H.P)<br />

<strong>Visual</strong> <strong>Basic</strong> 6.0 <strong>Tutorials</strong><br />

2. Full set of objects. We draw the application<br />

2. Lots of icons and pictures for use.<br />

2. Response to mouse and keyboard actions<br />

2. Clipboard and printer access.<br />

2. Full array of mathematical, string handling, and graphics function.<br />

2. Can handle fixed and dynamic variable and control arrays.<br />

2. Sequential and random access file support<br />

2. Useful debuggers and error handling facilities.<br />

2. Powerful database access tools.<br />

2. Activex support<br />

2. Package & deployment Wizard makes distributing applications simple.<br />

Q50 Write a program in VB to find the student standing second in a class.<br />

Ans. Public Type Student<br />

Name As String<br />

Marks As Double<br />

End type<br />

DIM S (10) as Student<br />

DIM Temp as student<br />

Public sub enterdata ()<br />

DIM | as Integer<br />

For I= 0 to 10<br />

S(I). Name= Inputbox (“Enter name”)<br />

S(I).marks = Val (Input box (“Enter marks”) )<br />

Next<br />

End sub<br />

Public sub show ()<br />

DIM I As Integer, ) as Integer<br />

For I = 0 to 10<br />

For J = 0 to 10<br />

IF S(I).marks > S(J).marks then<br />

Temp = S(I)<br />

S(I) = S(J)<br />

End If<br />

Next J<br />

Next I<br />

Msgbox S (1). name & “ is second”<br />

End sub<br />

Q51 Classify the operators in VB.<br />

Ans. Arithmetic operators:<br />

+ Used to add two numbers if is used with strings then it will concatenate both.<br />

- Used to subtract two values<br />

* Used to multiply the two numbers.<br />

/ Used to divide two numbers<br />

\ It is integer division operator.<br />

Mod Used to find modules<br />

Relational operators<br />

< less than<br />

< = less than or equal to<br />

> greater than<br />

> = greater than or equal to<br />

= to compare equality<br />

! Not equal to<br />

Logical operators String concalination<br />

AND, NOT, OR String concalination -------&<br />

Q52 Describe Menu Editor in VB.<br />

Ans. Menu editor is used to create new menus and members and new commands to existing menus,<br />

replace existing menu commands with your own commands and change and delete existing menus<br />

and members<br />

To display the Menu Editor<br />

Created By:- Ajay Verma


Om Edutech Institute Of IT & Applied Technologies <strong>Hamirpur</strong>(H.P)<br />

<strong>Visual</strong> <strong>Basic</strong> 6.0 <strong>Tutorials</strong><br />

From the Tools menu, choose Menu editor<br />

Or<br />

Click the Menu editor button on the toolbar.<br />

The two most important properties for menu controls are:<br />

0. Name: - This is the name you use to reference the menu control from code.<br />

0. Caption: - This is the text that appears on the control.<br />

Q53. Discuss the file handling facilities of VB.<br />

Ans. When we want to store data in visual <strong>Basic</strong> it can be in two forms: a database or an ASC || file.<br />

ASC|| files contain data of all types and can be formatted in a comma-separated values list; Three<br />

modes of files can be<br />

2. Sequential<br />

2. Random Access<br />

2. Binary<br />

Sequential: - When you want to store or retrieve data in VB you may choose to create a sequential<br />

file. A sequential file is a series of lines of text in ASC|| format.<br />

Random access: - Random access also works to retrieve data from ASC|| files, but you have<br />

greater flexibility when you use it instead of sequential mode. Random access allows you to<br />

position yourself anywhere within the file at any time to get the data you need.<br />

Binary Mode: - Binary mode allows you the greatest amount of flexibility when working with files.<br />

When working with binary access mode, you retrieve data sequentially and in chunks; - the binary<br />

mode. The number of bytes read form the file equals the size of the string, in bytes that you want to<br />

read data into.<br />

Q54. Write the enhance comments of VB 6.0 over VB 5.0.<br />

Ans. <strong>Visual</strong> <strong>Basic</strong> 5.0 released in late 1996. New environment supported creation of Active x controls.<br />

Deleted 16-bit application support.<br />

VB 6.0 includes new features:<br />

• Faster compiler<br />

• New Activex data control object<br />

• Allows database integration with wide variety of applications<br />

• New data report designer.<br />

• New package & report designers<br />

• Additional Internet capabilities.<br />

Q55. What are classes and objects? Discuss how to add properties, events and methods to a<br />

class module?<br />

Ans. A class is a self-sufficient piece of code, which means you can move the class from one project to<br />

another and it should, worked properly without any modification. A class contains properties and<br />

methods that all work together to perform a set of related operations. Object is instance of a class,<br />

which is used to access the members of class.<br />

Methods: - Adding method to a class is just like adding procedure to a code module. You can<br />

prefix the method name with Private or Public, depending on the scope of method.<br />

Properties: - are variables used to store and retrieve data from classes. Properties that are<br />

declared as public are said to be exposed. This means the data within the class can be accessed<br />

from another procedure outside the scope of the class. The exposed properties make up a portion<br />

of the class’s interface. Private properties can be used to keep data and procedures hidden behind<br />

the interface. This prevents programs from directly or unintentionally modifying the contents of data<br />

required for the class to function properly.<br />

Events: - are most interesting portion of class model. They allow the class to communicate<br />

information back to an application when sets of conditions are met. This makes the application<br />

event driven meaning it relies on events to make program operate.<br />

Q56. What are the different types of data reports? How are they created?<br />

Ans. Data report: - It is created by using data environment it may have grouping on some data. To<br />

create data report we must have data environment. After that add command for the report. Double<br />

click the Data Report object in the Project Explorer window.<br />

• Arrange the Data Environment window and the Data Report window so that both the<br />

windows are visible on the screen.<br />

• From data base environment drag the fields onto the appropriate section to add selective<br />

fields or drag command object to include all the fields in the report.<br />

• Each label control and text box control can be arranged in different section of the report<br />

by dragging and dropping as per the requirement set the data source property of Data<br />

Report object to the Data Environment and data member property to command.<br />

Crystal Reports: -<br />

Created By:- Ajay Verma


Om Edutech Institute Of IT & Applied Technologies <strong>Hamirpur</strong>(H.P)<br />

<strong>Visual</strong> <strong>Basic</strong> 6.0 <strong>Tutorials</strong><br />

Crystal reports let you customize many of the programs default settings to fit the layout<br />

your work. These setting affect such things as:<br />

0. Your working environment<br />

0. The way you select databases<br />

0. SQL and ODBC access<br />

0. The way various data types are formatted<br />

0. The fonts you use for fields and text.<br />

To create a crystal report-<br />

0. Open crystal Reports<br />

0. Click the new Report button on the button bar. The Report gallery appears<br />

( ) Click one of Report creation expert buttons for step-by-step help in creating a<br />

report.<br />

( ) Click the another Report button to use another report as a template for building<br />

your report.<br />

( ) Click the custom button to build a custom report.<br />

0. When you click custom button the Report Gallery expands.<br />

0. Select report type<br />

0. Select data source<br />

0. Select the fields<br />

0. Format the fields and labels. Apply any others format required on report.<br />

Q57 Explain the visual basic program development process.<br />

Ans. First step in creation of a VB program is to add project. From New tab choose the project template.<br />

After choosing the project type, add forms in your project. Set the properties of form. Third Add<br />

controls if it is simple form are using menu editor define the menu bar. Add controls on the form<br />

and set their properties.<br />

Define the code of controls for the actions events. Add module if necessary.<br />

Save forms and project. Set the default form to run.<br />

Q58. Explain the menu creation through menu editor in visual <strong>Basic</strong>.<br />

Ans. To design menu click on tools Menu editor. Menu editor dialog box will open<br />

Enter caption property and Name property in the first two boxes in menu editor.<br />

You can also choose a short cut key for the current menu control<br />

The left and right arrow buttons are for indenting and outdenting menu controls. A menu title must<br />

be flush with the left margin of the menu list box at the bottom. A menu item is usually indented<br />

once. You would indent a second time to create a submenu item (cascading menu) from the<br />

previous menu item.<br />

The up and down arrow buttons are for changing the order in which menu titles and menu items<br />

appear.<br />

You can type a number in the index field to make the menu control array. These are useful when<br />

you want to list like the ones you see at bottom of file menu in various applications.<br />

The help control ID field in used to link the help menu to a help file through a unique identifies<br />

called help context.<br />

Finally the Negotiate Position field in used to determine where a top-level menu would be<br />

positioned when an MDI child form is maximized and both forms must share the menu bar of MDI<br />

parent form.<br />

Q59. Explain the tasks involved in debugging the visual basic application.<br />

Ans. Debugging in a process by which errors are identified and resolved in source code. Typically<br />

debugging in conducted at various levels. These levels are termed level debugging, level2<br />

debugging, and level3 debugging.<br />

Level debugging: The first level of debugging is the implementation of a debugging procedure and<br />

the necessary tuning to make it operate as expected.<br />

Logical errors occur when the application does not perform as intended and produces correct<br />

results. When a programmer set to write a procedure he/she would have in mind only the expected<br />

output of that procedure. As the develops goes about writing the procedure, he/she finds a better<br />

method that solves many more constraints, thereby working better in the worst of circumstances<br />

also. This five tuning and developing of code functionality in such a way that the program runs<br />

efficiently in called level1 debugging.<br />

Level2 debugging: Second level debugging is the activity required to make a functional unit of<br />

code interact according to plan with other units of code a typically to plan with other units of code<br />

typically before shipping or deploying the completed project. Generally this condition arises when<br />

the user’s procedure does not run properly in a test case.<br />

Created By:- Ajay Verma


Om Edutech Institute Of IT & Applied Technologies <strong>Hamirpur</strong>(H.P)<br />

<strong>Visual</strong> <strong>Basic</strong> 6.0 <strong>Tutorials</strong><br />

Level3. Debugging: Level3 debugging is primarily the diagnosis and repairs of problems occurring<br />

in applications that have already been deployed. These bugs are often the most difficult to locate<br />

because they occur on a remote machine. They may be the result of unanticipated circumstances<br />

s. These may be one of the following:<br />

User actions<br />

Program configuration<br />

System configuration<br />

Q60. Explain the find methods to locate any record in the recordset.<br />

Ans. The find methods can be used to locate a record in a dynaset or snapset type recordset. VB<br />

supports four find methods.<br />

Find First: method finds the first record satisfying the specified criteria.<br />

Findlast: method finds the last record satisfying the specified criteria.<br />

Find Next: method finds the next record satisfying the specified criteria, searching forward the<br />

current record.<br />

Find Previous: method finds the previous record satisfying the specified criteria, searching<br />

backward from the current record.<br />

Q61. Write steps to create an MDI application.<br />

Ans. The Multiple Document Interface allows you to create an application that maintains multiple forms<br />

within a single container form. To create an MDI form and its child form use following procedure.<br />

5. Create MDI formby adding MDI form from project menu.<br />

5. Create the applications child form by setting forms MDI child property to true.<br />

Q62. What are various types of modules used in VB?<br />

Ans. <strong>Visual</strong> <strong>Basic</strong> has three basic modules<br />

Form module<br />

Standard module<br />

Class module.<br />

2. Form Module: Form module (.FRM file name extension) in the foundation of most visual <strong>Basic</strong><br />

applications. They can contain procedures that handle events. General procedures, and form<br />

level declarations of variables, constants types and external procedure. The code that you<br />

write in a form module in specific to the particular application to which the form belongs. IT<br />

might also refer to other forms or objects within that application.<br />

2. Standard Module: Standard module has BAS extension. There are containers for procedures<br />

and declarations commonly accessed by other modules within the applications. They can<br />

contain global or module level declarations of variables, constants types, external<br />

p[procedures, and global procedures. The code that you write in standard module isn’t<br />

necessarily tied to a particular application a standard module can be reused in many different<br />

applications.<br />

2. Class module: Its extension is .cls. These are used for object oriented programming in VB.<br />

You can write code in class modules to create new objects. These new objects can include<br />

your own customized properties and methods.<br />

Q64. What is use of static variables?<br />

Ans. You can preserve the value of local variable by making the variable static. Static keyword is used to<br />

declare the variable as static.<br />

For example.<br />

The following function calculates a running total by adding a new value to the total of previous<br />

values stored in the static variable accumulate:<br />

Function RunningTotal (num)<br />

Applessold= Applessold + num<br />

Running Total= Applessold<br />

End function<br />

If Applessold was declared with DIM instead of static, the previous accumulated values would not<br />

be preserved across calls to the function and the function would simple return the same value with<br />

which it was called.<br />

Q65. Define constant and its sources.<br />

Ans. A constant in a meaningful name that takes the place of numbers or string that does not change.<br />

Although constant some what resembles a variable, you can’t modify a constant or assign a new<br />

value to it as you can to a variable. There are two sources for constants:<br />

Intrinsic or system-defined:<br />

These constants are provided by applications and controls<br />

<strong>Visual</strong> <strong>Basic</strong> constants are listed in the visual <strong>Basic</strong> (VB) and <strong>Visual</strong> <strong>Basic</strong> for applications (VBA)<br />

object libraries in the object Browser. Other application that provide object Libraries also provide a<br />

Created By:- Ajay Verma


Om Edutech Institute Of IT & Applied Technologies <strong>Hamirpur</strong>(H.P)<br />

<strong>Visual</strong> <strong>Basic</strong> 6.0 <strong>Tutorials</strong><br />

list of constants you can use with their objects, methods and properties. Constants are also defined<br />

in object library for each Active X control.<br />

Symbolic or user-defined constants are declared using constant statement.<br />

Q66. Write a program to authenticate user/password pair.<br />

Ans. Make a project using standard.exe.<br />

Add a form. Add two text boxes.and two tables. Change caption of first label as username as<br />

second’s as password. Name of first textbox txtusr, and second’s txtpass.<br />

Add a command button and make its caption clickme.<br />

Double click on button to write code for click event.<br />

If txtusr = “Munish” and txtpass= “VB6” then Msgbox “Successful login”<br />

Else<br />

Msgbox “Login denied Reenter User name/Password”<br />

Txtusr = “ “<br />

Txtpass= “ “<br />

End If<br />

Q67. Explain break mode.<br />

Ans. It halts the operation of an application and gives a snapshot of its condition at any instant, as the<br />

program is still active; only i9ts execution is temporarily suspended. All variables retain their values<br />

properties and statements. In this mode you can modify an applications code, or observe the<br />

applications interface condition or determine the active procedures that have been called or even<br />

change the program flow.<br />

If visual <strong>Basic</strong> encounters any of the below mentioned statements, then it enters into the Break<br />

Mode.<br />

Breaks point<br />

Stop statement<br />

Break mode can be entered manually in several ways.<br />

2. Press ctrl + Break<br />

2. Select the Break button on the toolbar<br />

2. Press F5 while your program is running.<br />

Q67:- What do you understand by scope of a variable ? Differentiate between global<br />

variable and local variable.<br />

Ans :- scope of variable is depended upon the variable where it is declared or which keyword is used to<br />

declare the variable. Scope tells the life time of the variable. We can declare variables in two ways.<br />

0. Global<br />

0. Local<br />

0. Global :- When the variable are declared global in the general section then they are accessible with<br />

in the whole form . if with public keyword then they are accessible in whole project with form<br />

reference. If they are declared in module they are also called globally in the project. If these<br />

variables are declare with private or dim keyword in general section then these variables are<br />

callable with in the specified form only.<br />

0. local :- if the variables are declared with dim statement in any procedure of the form then they are<br />

accessible with in that procedure only. We can declare local variable with public or private<br />

keywords.<br />

Q68:- Name and explain in brief various components of <strong>Visual</strong> <strong>Basic</strong> IDE?<br />

Ans :- IDE is integrated development environment, which is used in the programming to describe<br />

the interface and environment that we use to create our applications. It is called integrated because<br />

we can access virtually all the development tools that were need from one screen is called<br />

interface.<br />

Main elements or components of IDE are:<br />

• Menu bar :- It contains different types of menus and a group of similar types instructions<br />

are store in a single menu.<br />

• Tool bar :- it contains the shortcuts of the commands those are appears in different<br />

menus. Using these we don’t have any need to open menu again & again. We can select<br />

from the toolbar.<br />

• Project explorer :- it contains list of forms, module and class modules used in the project<br />

• Properties window :- contains the list of properties of the selected control.<br />

• Toolbox :- contains all the implicit controls used in VB.<br />

Created By:- Ajay Verma


Om Edutech Institute Of IT & Applied Technologies <strong>Hamirpur</strong>(H.P)<br />

<strong>Visual</strong> <strong>Basic</strong> 6.0 <strong>Tutorials</strong><br />

• Form Designer :- here we can design the form for vb project.<br />

• Object Browser :- allow us to browse through the various properties, event, and methods<br />

that are made available, or exposed to you.<br />

Q 69:- Explain how a recordset can be created in <strong>Visual</strong> <strong>Basic</strong>?<br />

Ans :- Recordset stroes the results of the execution of command object in a database. Recordset can be<br />

created without an explicit connection. To access the fields of a recordset object, we can use field’s<br />

collection.<br />

Using the following code we can create recordset in vb<br />

Dim cn as new adodb.connection<br />

Dim rs as new adodb.recordset<br />

Cn.open “provider=Microsoft.Jet.Oledb.4.0; Data Source=’c:\student.mdb’”<br />

Rs.open “select * from student”,cn,adopendynamic,adlockoptimistic<br />

To fetch the values from the recordset the following code is used.<br />

Recordset.fields(“fieldname”)<br />

Or<br />

Recordset(indexno)<br />

e.g<br />

msgbox rs(0)<br />

or<br />

msgbox rs.fields(“Name”)<br />

Q 70:- Explain the function and use of Err Object?<br />

Ans :- ErrObject is class in vb to handle errors. It has number of properties and functions.<br />

1.clear :- this method is to clear all the property settings of the error object.<br />

2escription :- return or sets the string expression a descriptive string associated with the error objects.<br />

3HelpContext :- return or sets a context ID for a topic in a help file.<br />

4.helpfile :- return or sets the fully qualified path for help file.<br />

5. lastDLLerror :- returns the system error code by call to DLL.<br />

6.Number :- returns or set a numeric value representing an error.<br />

7.raise :- this function will generate an error at runtime.<br />

8. source :- returns or sets the name of the object that originated the error<br />

Q 71:- Write a VB program that takes a number from user with an input box and displays<br />

its multiplication table in immediate window.<br />

Ans:<br />

Dim n As Integer<br />

n = InputBox("enter number")<br />

For i = 1 To 10<br />

c = n * i<br />

Debug.Print n, "*", i, "=", c<br />

Next<br />

Q 72;- Write a VB program to implement a calculator that coverts a number given a textbox<br />

to its equivalent Binary Hexadecimal and octal number on the click of respective buttons<br />

and display the result in another textbox.<br />

Ans:<br />

Private Sub Cmdbinary_Click()<br />

Text2 = ""<br />

n = Text1<br />

While n > 0<br />

s = n Mod 2<br />

Text2 = Text2 & s<br />

n = Int(n / 2)<br />

Wend<br />

Text2 = StrReverse(Text2)<br />

End Sub<br />

Private sub cmdoct_click()<br />

Created By:- Ajay Verma


Om Edutech Institute Of IT & Applied Technologies <strong>Hamirpur</strong>(H.P)<br />

<strong>Visual</strong> <strong>Basic</strong> 6.0 <strong>Tutorials</strong><br />

Text2=oct(text1)<br />

End sub<br />

Private sub cmdhexa_click()<br />

Text2=hex(text1)<br />

End sub<br />

Q 73 Explain in detail the difference between tables, dynasets and snapshots<br />

Ans :-Table:- the table is only one of the potentially many components that will actually make up a<br />

database. tables are the starting point for any database, and they are where the data is stored. Without a<br />

minimum of one table, a database would contain no data and be totally meaningless.<br />

Dynaset :- Dynaset means dynamic set of records . the data in a dynaset does not actually exist-it is extract<br />

from the underlying table or tables and only the criteria are saved. There are some restrictions on editing in<br />

a dynaset.You may not be able to edit data if it threatens referential integrity between more than one table<br />

or master and client table..<br />

Snapshot :- The snapshot type recordset can refer to any table, attached table or query. A snapshot cannot<br />

be update and does not reflect any change made by users.<br />

Q 74: -What modality is and how does it affect the behaviour of your dialog boxes?<br />

Ans :- Modality means whether the dialog box gives its control to next dialog or form without closing or<br />

not. There are two types of dialog boxes.<br />

1 Modal<br />

2 Mode less<br />

Modal :- if the dialog box are modal then the control will not transfer to their master form without giving<br />

the necessary information to the dialog box or close it. E.g of these dialog boxes are msgbox ,inputbox in<br />

VB.<br />

2. mode less :- if the dialog box are mode less than control can be transfer to the master form without<br />

closing the dialog box. E.g of these dialog box is find & replace dialog box.<br />

Q 75 What do you understand by bug(error)? What are the different types of bugs that you may<br />

encounter while programming with visual basic?<br />

Ans Bugs are the errors. These bugs are appear in vb application in different situation and can terminate<br />

the vb application. Some bugs will not terminate the application but produce wrong result. All<br />

these bugs are divided to the following categories.<br />

Syntax bug: These errors occur when we enter an incorrect line of code . Such as a mistake in<br />

typing a keyword, a punctuation is missing or an incorrectly spelled variable.<br />

Runtime bug: These occur when a command attempts to perform an action that is not valid. For<br />

example, a runtime error occurs if we try to assign a string to a numeric variable. Errors handlers<br />

execute only if a run-time errors is encountered.<br />

Logical bug: Occurs when an application executes without syntax error or run-time errors, but the<br />

results are not what we intend. For example, an application might prompt the user for a password<br />

but then may not allow access to the application even if the password is correct.<br />

Q 76:- What is the difference between List View and Tree View? Explain with example.<br />

Ans:- Tree View :- The Tree View control provides a hierarchical view of folders or other items that can be<br />

neatly categorized in a tree- style layout. It is often used in conjunction with a List View control, which is<br />

used to display the contents of the folder selected in the Tree View. This is the ActiveX control which is<br />

available in common window control.<br />

Main properties of Tree View<br />

Name, ImageList, Indentation OLEDragMode, OLEDropMode, LineStyle, Scroll etc<br />

List View :- List View control provides a detailed view of the items appear in the specified folder that we<br />

select in the tree view. Normally this is used with conjunction of tree view. But we can use it separately<br />

also. Any selected item can execute. This also one of the ActiveX control and is available in Common<br />

window controls.<br />

Main Properties of List View<br />

Arrange , SelectedItem ,Name, LabelEdit, LabelWrap, Listitems, view , GridLines etc.<br />

Q77 :- Write a function subprogram to covert the temperature in Fahrenheit to Celsius.<br />

Created By:- Ajay Verma


Om Edutech Institute Of IT & Applied Technologies <strong>Hamirpur</strong>(H.P)<br />

<strong>Visual</strong> <strong>Basic</strong> 6.0 <strong>Tutorials</strong><br />

Ans:-<br />

Public Function ftoc(f As Double) As Double<br />

ftoc = 5 / 9 * (f - 32)<br />

End Function<br />

Using the following statements we can call that function on click of a command button<br />

Private sub command1_click()<br />

Dim f a double<br />

f=inputbox(“enter Fahrenheit”)<br />

msgbox ftoc(f)<br />

end sub<br />

Q78 :- Explain in detail steps needed to change the data in a database record<br />

Ans :- suppose we have student table in micorosoft access student.mdb database and we want to modify the<br />

record we have to perform the following steps.<br />

3. Include reference of ADODB library<br />

3. initialize connection and recordset using following commands in general section<br />

dim cn as new ADODB.connection<br />

dim rs as new ADODB.recordset<br />

3. open connection and recordset on the form activation using following command<br />

cn.open “provider=Microsoft.Jet.Oledb.4.0;Data source=” &app.path &”\student.mdb”<br />

rs.open “select * from student”,cn,adopendynamic, adopenlocopticmistic<br />

3. create a find button to find the record to update and write following commands<br />

private sub cmdfind_click()<br />

dim rno as integer<br />

rno=inputbox (“enter rollno to find”)<br />

rs.movefirst<br />

rs.find “rollno=” & rno<br />

if rs.eof then<br />

msgbox “record not found”<br />

else<br />

txtrollno=rs(“rollno”)<br />

txtname=rs(‘name”)<br />

txtclass=rs(“class”)<br />

end sub<br />

5 modify data what ever u want to modify in the textboxes and click on update button that have the<br />

followng code<br />

private sub cmdupdate_click()<br />

cn.execute “update student set rollno=” &txtrollno &” , name=’” & txtname &”’,class=’”& txtclass & “<br />

where rollno= “ &txtrollno<br />

end sub<br />

Q79 : Write an application that will put a new Textbox control on form every time you click<br />

the command button?<br />

Ans<br />

Dim i As Integer<br />

Private Sub Command1_Click()<br />

i = i + 1<br />

Load Text1(i)<br />

Text1(i).Visible = True<br />

Text1(i).Top = Text1(i - 1).Top + Text1(i - 1).Height<br />

End Sub<br />

Private Sub Form_Activate()<br />

i = 0<br />

Created By:- Ajay Verma


End Sub<br />

Om Edutech Institute Of IT & Applied Technologies <strong>Hamirpur</strong>(H.P)<br />

<strong>Visual</strong> <strong>Basic</strong> 6.0 <strong>Tutorials</strong><br />

Q80 Create a project that contains a picture box and two buttons labeled smile and frown.<br />

The smile button will display a happy face in the picture box and frown will display a sad<br />

face. Use pgraphics methods to draw the two faces.<br />

Ans:-<br />

Private Sub Command1_Click()<br />

Picture1.Cls<br />

Picture1.FillStyle = vbSolid<br />

Picture1.FillColor = vbYellow<br />

Picture1.Circle (Picture1.ScaleHeight / 2, Picture1.ScaleWidth / 2), 500<br />

Picture1.FillColor = vbRed<br />

Picture1.Circle (Picture1.ScaleHeight / 3 + 130, Picture1.ScaleWidth / 3 + 100), 100<br />

Picture1.Circle (Picture1.ScaleHeight / 3 + 500, Picture1.ScaleWidth / 3 + 100), 100<br />

Picture1.Circle (Picture1.ScaleHeight / 2, Picture1.ScaleWidth / 2), 200, 2, 3<br />

End Sub<br />

Private Sub Command2_Click()<br />

Picture1.Cls<br />

Picture1.FillStyle = vbSolid<br />

Picture1.FillColor = vbGreen<br />

Picture1.Circle (Picture1.ScaleHeight / 2, Picture1.ScaleWidth / 2), 500<br />

Picture1.FillColor = vbRed<br />

Picture1.Circle (Picture1.ScaleHeight / 3 + 130, Picture1.ScaleWidth / 3 + 100), 100<br />

Picture1.Circle (Picture1.ScaleHeight / 3 + 500, Picture1.ScaleWidth / 3 + 100), 100<br />

Picture1.Circle (Picture1.ScaleHeight / 2, Picture1.ScaleWidth / 2 + 300), 200, , 0, 3<br />

End Sub<br />

Created By:- Ajay Verma


Om Edutech Institute Of IT & Applied Technologies <strong>Hamirpur</strong>(H.P)<br />

<strong>Visual</strong> <strong>Basic</strong> 6.0 <strong>Tutorials</strong><br />

Q81 :- What care has to be taken while adding updataing and deleting records from linked<br />

tables?<br />

Ans :- following things we have to care while adding , updating and deleting records<br />

0. if any new record is added in the linked table it must have the reference value from the main table<br />

otherwise no insertion is possible<br />

0. if any record is going to update we should change reference key in the secondary table<br />

0. before deleting the records from the parent table all the reference records must be deleted from<br />

the child table.<br />

0. Before updating the key field in parent table must remove the reference of that value from the<br />

child table.<br />

Q82: -What are the common errors in the visual basic?<br />

Ans :- In vb the error can be divided into the following category.<br />

Syntax errors: These errors occur when we enter an incorrect line of code . Such as a mistake in typing<br />

keyword, a punctuation is missing or an incorrectly spelled variable.<br />

Runtime error: These occur when a command attempts to perform an action that is not valid. For<br />

example, a runtime error occurs if we try to assign a string to a numeric variable. Errors handlers execute<br />

only if a run-time errors is encountered.<br />

Logic Errors: Occurs when an application executes without syntax error or run-time errors, but the results<br />

are not what we intend. For example, an application might prompt the user for a password but then may not<br />

allow access to the application even if the password is correct.<br />

Q83:- Write a program that verifies the order in which event occur for the user control. Use<br />

debug.print statement to display the name of each event as it occurs.<br />

Ans : - the following cade we can specify to find the occurrence of event in the user control. And to print<br />

the message on the debug window.<br />

Private Sub UserControl_Initialize()<br />

MsgBox "inalizining event"<br />

Debug.Print "inalizining event"<br />

End Sub<br />

Private Sub UserControl_Paint()<br />

MsgBox "painting event"<br />

Debug.Print "painting event"<br />

End Sub<br />

Private Sub UserControl_Resize()<br />

MsgBox "resize event"<br />

Debug.Print "resize event"<br />

End Sub<br />

Private Sub UserControl_Terminate()<br />

MsgBox "terminate event"<br />

Debug.Print "terminate event"<br />

End Sub<br />

Q84 :- Describe the basic concept of array handling in visual basic.<br />

Ans :- Array are the group of elements with single name with similar data type in the continues memory<br />

location. Concept behinde defining the array in vb is that it is difficult member number of variable using<br />

array we can specify the single those are using the same data type and can give different using the different<br />

index value of the array. The following syntax is used to define the array in VB.<br />

Syntax<br />

Dim variable(upperbound) as datatype<br />

e.g<br />

dim rollno(5) as integer<br />

Created By:- Ajay Verma


Om Edutech Institute Of IT & Applied Technologies <strong>Hamirpur</strong>(H.P)<br />

<strong>Visual</strong> <strong>Basic</strong> 6.0 <strong>Tutorials</strong><br />

In vb we can create the arrays of control if we defining the same control in numbers of time in the form.<br />

This makes the control handling process easy with in the single event which is common to all of the<br />

control can recognize different controls with their index number.<br />

We can create the array of control by inserting the control on the form the using copy and paste option at<br />

design time of the form.<br />

Q85 :- Briefly describe the difference between design mode and run mode?<br />

Ans :- The VB provide two types of modes for an application these modes are<br />

0. design mode<br />

0. run mode<br />

design mode :- when form is open in this mode . we can place different controls that we want must appear<br />

on the form at run time. If we want to sum of control should not work we can specify the disable property<br />

of these controls at design time some of the properties of controls those we can not specify at run time it<br />

can also be specified at design time. At design time using form layout window we can also position the<br />

form for the run time appearance. Shape and line control doesn’t provide any event so it is normally used at<br />

design time.<br />

Run mode :- this mode specify the codes that will execute when we run the form. In which we can specify<br />

the control position according to form size at runtime. The code for events those are attached with different<br />

controls of the form can only define in the run mode. We can define different types of procedures those are<br />

called by the events of the control at runtime.<br />

Q86 List out the mouse pointer properties with at least one pointer example?<br />

Ans :- Returns or sets a value indicating the type of mouse pointer displayed when the mouse is over a<br />

particular part of an object at run time.<br />

The settings for value are:<br />

Constant Value Description<br />

vbDefault 0 (Default) Shape determined by the object.<br />

vbArrow 1 Arrow.<br />

vbCrosshair 2 Cross (crosshair pointer).<br />

vbIbeam 3 I beam.<br />

vbIconPointer 4 Icon (small square within a square).<br />

vbSizePointer 5 Size (four-pointed arrow pointing north, south, east, and<br />

west).<br />

vbSizeNESW 6 Size NE SW (double arrow pointing northeast and<br />

southwest).<br />

vbSizeNS 7 Size N S (double arrow pointing north and south).<br />

vbSizeNWSE 8 Size NW SE (double arrow pointing northwest and<br />

southeast).<br />

vbSizeWE 9 Size W E (double arrow pointing west and east).<br />

vbUpArrow 10 Up Arrow.<br />

vbHourglass 11 Hourglass (wait).<br />

vbNoDrop 12 No Drop.<br />

vbArrowHourglass 13 Arrow and hourglass.<br />

vbArrowQuestion 14 Arrow and question mark.<br />

vbSizeAll 15 Size all.<br />

vbCustom 99 Custom icon specified by the MouseIcon property.<br />

Created By:- Ajay Verma


Om Edutech Institute Of IT & Applied Technologies <strong>Hamirpur</strong>(H.P)<br />

<strong>Visual</strong> <strong>Basic</strong> 6.0 <strong>Tutorials</strong><br />

This example changes the mouse pointer to an hourglass while circles are drawn across the screen and then<br />

changes the hourglass back to a pointer at the end of the procedure. To try this example, paste the code into<br />

the Declarations section of a form. Press F5 to run the program, and then click the form.<br />

Private Sub Form_Click ()<br />

Dim I .<br />

Screen.MousePointer = vbHourglass<br />

' Set random color and draw circles on form.<br />

For I = 0 To ScaleWidth Step 50<br />

ForeColor = RGB(Rnd * 255, Rnd * 255, Rnd * 255<br />

Circle (I, ScaleHeight * Rnd), 400<br />

Next<br />

' Return mouse pointer to normal. Screen.MousePointer = vbDefault<br />

End Sub<br />

Q87 ;- Explain DLL and immediate window.<br />

Ans : - DLL Stands form Dynamic linking library. A .DLL file that contains one or more functions<br />

compiled, linked, and stored separately from the processes that use them. The operating system maps the<br />

DLLs into the process's address space when the process is starting up or while it is running. The process<br />

then executes functions in the DLL. In VB we can create DLL using ActiveX DLL project.<br />

Immediate window :- show the immediate result of the calculation performed in debug window. Print<br />

method debug object is used send output to the immediate window. So this window is one of the part of<br />

debug process in VB to make VB code error free. We can find result of an expression by calculating<br />

directly in immediate window in break mode.<br />

Q88 : - What do you mean by ActiveX controls ? How they are useful in application development?<br />

Ans :-<br />

ActiveX controls add power to your Application form. In addition to creating your own controls, you can<br />

use the Internet controls provided with the Professional and Enterprise editions of <strong>Visual</strong> <strong>Basic</strong> to extend<br />

standard applications with Internet technology. For example, you can use ActiveX controls on a Web page<br />

to add customized menus to your Web pages, add a scrolling banner you can use to present advertisements<br />

or important announcements, or add animated effects. Window Common dialog control provides inbuilt<br />

dialog mechanism that is create a simple notepad application.<br />

ActiveX provide number of features those helps developers in development.<br />

Q 89:- Explain the difference between SDI and MDI applications. Give suitable example.<br />

Ans :- <strong>Visual</strong> <strong>Basic</strong> provides a great deal of flexibility, allowing you to configure the working environment<br />

to best suit your individual style. You can choose between a single or multiple document interface, and you<br />

can adjust the size and positioning of the various Integrated Development Environment (IDE) elements.<br />

Your layout will persist between sessions of <strong>Visual</strong> <strong>Basic</strong>.<br />

SDI or MDI Interface<br />

Two different styles are available for the <strong>Visual</strong> <strong>Basic</strong> IDE: single document interface (SDI) or multiple<br />

document interface (MDI). With the SDI option, all of the IDE windows are free to be moved anywhere on<br />

screen; as long as <strong>Visual</strong> <strong>Basic</strong> is the current application, they will remain on top of any other applications.<br />

With the MDI option, all of the IDE windows are contained within a single resizable parent window. Any<br />

single<br />

Created By:- Ajay Verma


Om Edutech Institute Of IT & Applied Technologies <strong>Hamirpur</strong>(H.P)<br />

<strong>Visual</strong> <strong>Basic</strong> 6.0 <strong>Tutorials</strong><br />

document interface is converted into the multiple document interface by set true value to the MDICHILD<br />

property of the form.<br />

e.g in Vb project the following form is created to perform calculate the sum of two numbers. And another<br />

form shows the welcome message.after inserting an MDI form in the project. We can convert these SDI<br />

form into the MDI with MDICHILD properties of these form<br />

single document interface First form<br />

Single document Interface (Second form)<br />

Created By:- Ajay Verma


Vaishnoo Maa Computers,[Cal-c] A Study Centre of PTU<br />

Subject:-Question Bank of <strong>Visual</strong> <strong>Basic</strong> Page No 44 of 48<br />

set firstform.mdichild=true<br />

set secondform.mdichild=true<br />

to make these interface for multiple document interface.<br />

Q90 : - Explain Application deployment with VB?<br />

Ans :- The Package and Deployment Wizard packages your project .dll files and all associated files into a<br />

"cabinet" or .cab file. The wizard can then deploy this cabinet file and its associated support files to a<br />

location you indicate on a Web server.<br />

The application files that must be deployed include:<br />

• The .dll files for the project — including the <strong>Visual</strong> <strong>Basic</strong> run-time DLL and the .dsr and .dsx files<br />

for the project. These are automatically packaged into the .cab file when you run the Package and<br />

Deployment Wizard.<br />

• The HTML page or pages associated with the project. The Package and Deployment Wizard does<br />

not package these into the .cab file, but it copies them to the indicated location on the Web site<br />

when you deploy the .cab file.<br />

• Any files referenced by the HTML pages, such as images. The Package and Deployment Wizard<br />

does not automatically recognize these dependencies, but you can add them to the list of additional<br />

files to deploy.<br />

The Deployment Process<br />

These are the steps in deploying your DHTML application to the Internet:<br />

0. Debug and compile your application.<br />

0. Use the Package and Deployment Wizard to build a .cab file that contains the necessary files for<br />

your application.<br />

0. Digitally sign your .cab file and rebuild.<br />

0. Use the Package and Deployment Wizard to deploy your application to the Web server you want<br />

to use.<br />

0. Manually copy any files associated with your application’s HTML pages, such as images, to the<br />

necessary location on your Web server.<br />

Q91 : - Explain the following<br />

Image control<br />

Command button control<br />

Ans 1. image control :- An Image control can display a graphic from a bitmap, icon, or metafile, as well as<br />

enhanced metafile, JPEG, or GIF files. The Image control uses fewer system resources and repaints faster<br />

than a PictureBox control, but it supports only a subset of the PictureBox properties, events, and methods.<br />

Use the Stretch property to determine whether the graphic is scaled to fit the control or vice versa.<br />

Although you can place an Image control within a container, an Image control can't act as a container.<br />

Properties :- there are two main properties of image control are<br />

Picture :- in the picture property the image that we wan to display on the image control can set.<br />

Stretch :- returns or sets whether the image/ graphics resizes to fit the size of an image control.<br />

2. Command Button : - The easiest way to allow the user to interact with an application is to provide a<br />

button to click. You can use the command button control provided by <strong>Visual</strong> <strong>Basic</strong>. Most <strong>Visual</strong> <strong>Basic</strong><br />

applications have command buttons that allow the user to simply click them to perform actions. When the<br />

user chooses the button, it not only carries out the appropriate action, it also looks as if it's being pushed in<br />

and released. Whenever the user clicks a button, the Click event procedure is invoked<br />

Command button control has the default event click and default property is caption.<br />

Q92 :- Explain the followings


Vaishnoo Maa Computers,[Cal-c] A Study Centre of PTU<br />

Subject:-Question Bank of <strong>Visual</strong> <strong>Basic</strong> Page No 45 of 48<br />

Function procedures<br />

Event procedures<br />

Ans : - Event procedure : - When an object in <strong>Visual</strong> <strong>Basic</strong> recognizes that an event has occurred, it<br />

automatically invokes the event procedure using the name corresponding to the event. Because the name<br />

establishes an association between the object and the code, event procedures are said to be attached to<br />

forms and controls.<br />

• An event procedure for a control combines the control's actual name (specified in the Name<br />

property), an underscore (_), and the event name. For instance, if you want a command button<br />

named cmdPlay to invoke an event procedure when it is clicked, use the procedure<br />

cmdPlay_Click.<br />

• An event procedure for a form combines the word "Form," an underscore, and the event name. If<br />

you want a form to invoke an event procedure when it is clicked, use the procedure Form_Click.<br />

(Like controls, forms do have unique names, but they are not used in the names of event<br />

procedures.) If you are using the MDI form, the event procedure combines the word "MDIForm,"<br />

an underscore, and the event name, as in MDIForm_Load.<br />

Function Procedures : - a Function procedure is a separate procedure that can take arguments, perform a<br />

series of statements, and change the value of its arguments. Unlike a Sub procedure, a Function procedure<br />

can return a value to the calling procedure. There are three differences between Sub and Function<br />

procedures:<br />

• Generally, you call a function by including the function procedure name and arguments on the<br />

right side of a larger statement or expression (returnvalue = function()).<br />

• Function procedures have data types, just as variables do. This determines the type of the return<br />

value. (In the absence of an As clause, the type is the default Variant type.)<br />

• You return a value by assigning it to the procedurename itself. When the Function procedure<br />

returns a value, this value can then become part of a larger expression.<br />

Q92 : - Explain ActiveX Documents?<br />

Ans :- ActiveX documents (.dob) are similar to forms, but are displayable in an Internet browser such as<br />

Internet Explorer. The Professional and Enterprise editions of <strong>Visual</strong> <strong>Basic</strong> are capable of creating ActiveX<br />

documents<br />

Following steps are used to create ActiveX document.<br />

0. Determine the features your document will provide.<br />

0. Design the appearance of your document.<br />

0. Design the interface for your document; that is, the properties, methods, and events your document<br />

will expose.<br />

0. Create a project consisting of your user document and any auxiliary forms.<br />

0. Add controls and/or code to the UserDocument object.<br />

0. Implement the interface and features of your document.<br />

0. Compile your document to create a .vbd file and test it with all potential target applications<br />

Q93 : - Explain the different Advanced Data Access issues ?<br />

Ans :- Following are five data access scenarios that are more complex than simple Select queries.<br />

• Executing a Parameter Query<br />

• Performing a Parameter-Driven Stored Procedure<br />

1. Executing a Parameter Query : - ADO gives you a lot of flexibility here—more, in some cases<br />

than RDO. Following commands are used to create parameter query<br />

Private Sub ParmQueryButton_Click()<br />

If Cmd.CommandText = "" Then<br />

Cmd.ActiveConnection = cn<br />

With Cmd<br />

.CommandText = "select * from authors where year_born = ?"<br />

.CommandType = adCmdText


Vaishnoo Maa Computers,[Cal-c] A Study Centre of PTU<br />

Subject:-Question Bank of <strong>Visual</strong> <strong>Basic</strong> Page No 46 of 48<br />

End With<br />

With Parm<br />

.Type = adInteger<br />

.Size = 4<br />

.Direction = adParamInput<br />

.Value = QueryParam.Text<br />

Cmd.Parameters.Append Parm<br />

End With<br />

End If<br />

Cmd.Parameters(0).Value = QueryParam.Text<br />

Set rs = Cmd.Execute()<br />

ADOGrid1.ShowData rs<br />

rs.Close<br />

End Sub<br />

2.Performing a Parameter-Driven Stored Procedure :- it's possible to build your own ADODB<br />

Parameters collection. In this case, you’re performing a simple two-argument SP, "AuthorByYearBorn",<br />

that returns a small resultset<br />

Private Sub RunSPButton_Click()<br />

Dim Qy As New ADODB.Command<br />

Dim Parm As New ADODB.Parameter<br />

Dim Parm2 As New ADODB.Parameter<br />

Set Qy.ActiveConnection = cn<br />

Qy(0)="1947"<br />

Qy(1)="1948"<br />

Qy.CommandType = adCmdStoredProc<br />

Qy.CommandText = "AuthorByYearBorn"<br />

Set rs = Qy.Execute(ShowRows)<br />

ADOGrid1.ShowData rs<br />

End Sub<br />

Q 94 :- Explain the following<br />

(a)Opening a table for exclusive use<br />

(b)Data–Grid Controls<br />

The value of this property, along with the DatabaseName, ReadOnly, and Connect properties, is used to<br />

open a database. In the Professional and Enterprise Editions, this property corresponds to the exclusive<br />

argument in the OpenDatabase method.<br />

The Exclusive property is used only when opening the Database. If you change the value of this property<br />

at run time, you must use the Refresh method for the change to take effect. If someone else already has the<br />

database open, you can't open it for exclusive use and a trappable error results.<br />

Database operations are faster if the database is opened for exclusive use.<br />

After you open a database for exclusive use, your application can have as many instances open as<br />

necessary. However, other applications running on your system are not permitted to open the database.<br />

(b) Data Grid Controls : - The data-aware DataGrid control appears similar to the Grid control; however,<br />

you can set the DataGrid control's DataSource property to a Data control so that the control is<br />

automatically filled and its column headers set automatically from a Data control's Recordset object. The<br />

DataGrid control is really a fixed collection of columns, each with an indeterminate number of rows.<br />

Each cell of a DataGrid control can hold text values, but not linked or embedded objects. You can specify<br />

the current cell in code, or the user can change it at run time using the mouse or the arrow keys. Cells can<br />

be edited interactively, by typing into the cell, or programmatically. Cells can be selected individually or by<br />

row.<br />

If a cell's text is too long to be displayed in the cell, the text wraps to the next line within the same cell. To<br />

display the wrapped text, you must increase the cell's Column object's Width property and/or the<br />

DataGrid control's RowHeight property. At design time, you can change the column width interactively<br />

by resizing the column or by changing the column's width in the Column object's property page.


Vaishnoo Maa Computers,[Cal-c] A Study Centre of PTU<br />

Subject:-Question Bank of <strong>Visual</strong> <strong>Basic</strong> Page No 47 of 48<br />

Use the DataGrid control's Columns collection's Count property and the Recordset object's<br />

RecordCount property to determine the number of columns and rows in the control. A DataGrid control<br />

can have as many rows as the system resources can support and up to 32767 columns.<br />

When you select a cell, the ColIndex property is set, thus selecting one of the Column objects in the<br />

DataGrid object's Columns collection. The Text and Value properties of the Column object reference the<br />

contents of the current cell. The data in the current row can be accessed using the Bookmark property,<br />

which provides access to the underlying Recordset object's record. Each column of the DataGrid control<br />

has its own font, border, word wrap, and other attributes that can be set without regard to other columns. At<br />

design time, you can set the column width and row height and establish columns that are not visible to the<br />

user. You can also prevent users from changing the formatting at run time.<br />

Q95 : - Explain the following<br />

(a) Web Based deployment<br />

(b) Packaging the Applications<br />

Ans : -(a) :- These are the steps in deploying your web base application to the Internet:<br />

0. Debug and compile your application.<br />

0. Use the Package and Deployment Wizard to build a .cab file that contains the necessary files for<br />

your application.<br />

0. Digitally sign your .cab file and rebuild.<br />

0. Use the Package and Deployment Wizard to deploy your application to the Web server you want<br />

to use.<br />

0. Manually copy any files associated with your application’s HTML pages, such as images, to the<br />

necessary location on your Web server.<br />

0. Test the pages in your application to make sure that all the links to associated files still work. If<br />

not, you may have to adjust the location of your files on the Web server to match the URLs in the<br />

HTML pages.<br />

(b) Packaging the Application Application<br />

Using the Package and Deployment Wizard, you can easily create a professional setup program for your<br />

application or deploy an Internet application to the Web. The wizard performs these steps during the<br />

packaging process:<br />

• Automatic inclusion of your application's main setup program (setup1.exe). The wizard adds<br />

the Setup Toolkit application, Setup1.exe, to the package. This file is the main installation<br />

program for your application.<br />

• Automatic creation of your application's .cab files. The Package and Deployment Wizard can<br />

create a single .cab file or multiple .cab files for your application.<br />

• Script-based sessions. You can select a script from another packaging session with the same<br />

project if you want to use the same or very similar settings as you move through the wizard. This<br />

can save you significant time.<br />

• Optional creation of dependency files. Dependency files identify the run-time files that must be<br />

included with your application when it is distributed.<br />

• Automatic support for data access, Remote Automation, and DCOM features. The wizard<br />

automatically determines whether your project includes functionality that changes the setup<br />

process. For example, if you include certain types of data access, Remote Automation, or DCOM<br />

features, you may need to include drivers or other files in your package. The wizard checks your<br />

projects and displays screens that allow you to specify the appropriate options in these cases.<br />

• Shared file capability. The wizard allows you to install some files as shared files. This means that<br />

the files will not be removed from the system during an uninstall if other applications are using<br />

them.<br />

• Alternate file locations for Internet packages. In Internet packages, the wizard allows you to<br />

specify whether dependency files should be included in the setup program or downloaded from an<br />

alternate Web site.<br />

• Safety settings for Internet packages. If you do not use the IObjectSafety interface in your<br />

project, the Package and Deployment Wizard lets you mark components in your application as<br />

safe.


Vaishnoo Maa Computers,[Cal-c] A Study Centre of PTU<br />

Subject:-Question Bank of <strong>Visual</strong> <strong>Basic</strong> Page No 48 of 48<br />

• Custom destination locations for each file in the project. Most files have a default location to<br />

which they are installed, depending on whether they are project files or system files. You can<br />

change these locations if you want to install the files to a different location.<br />

Q 96:- (a) How can you create your own object?<br />

(b) What are the data bound Control.<br />

Ans : -(a) Class modules (.CLS file name extension) are the foundation of object-oriented<br />

programming in <strong>Visual</strong> <strong>Basic</strong>. You can write code in class modules to create new objects. These new<br />

objects can include your own customized properties and methods. Actually, forms are just class<br />

modules that can have controls placed on them and can display form windows. Following steps are<br />

applied to create new object.<br />

Add class module from the project menu in your project<br />

0. Define variable as private and procedure as public so that they are accessible out side<br />

0. save the class module and refer in the form procedure by specifying the following statements.<br />

Dim objectname as new classname<br />

Or<br />

Dim objectname as classname<br />

Set ojectname=classname<br />

(b) Data bound Control :-<br />

<strong>Visual</strong> <strong>Basic</strong> allows you to mark properties of your control as bindable, allowing you to create data-aware<br />

controls. A developer can associate bindable properties with fields in any data source, making it easier to<br />

use your control in database applications.<br />

The controls supplied with <strong>Visual</strong> <strong>Basic</strong> can be bound to data source fields using their DataSource and<br />

DataField properties : - You can select one property of your control to be bound to the DataField property.<br />

Typically, this will be the most important piece of data your control holds.<br />

Although you can mark only one field as bound to the field specified in the DataField property, you can<br />

mark additional properties of your ActiveX control as bindable. Developers can use the DataBindings<br />

collection to bind these additional bindable properties to data fields.

Hooray! Your file is uploaded and ready to be published.

Saved successfully!

Ooh no, something went wrong!