You are on page 1of 6

Question Answers in Visual Basic

1. Differentiate between the for next and for eachnext loop of Visual Basic giving a suitable example of each. Ans. For eachnext loop is used to iterate through all the elements contained in an array or a collection, whereas a fornext loop is used to iterate a fixed number of times depending upon the initial, terminating and the step values. Ex Ex For next loop For each..next For i=1 to 5 Dim a(3) As Integer, i As Variant Print i i=0 Next i a(0) = 6 a(1) = 5 a(2) = 4 a(3) = 3 For Each i In a Print i Next i 2. Name and explain the usage of any two types of modules available in Visual Basic. Ans. A module is a group of related code segments and associated variable declaration. It is stored as a single entity in the file system and it serves as a container for the code blocks/variables declared in it. The different types of modules are: i) Form module: All the forms that are added to a VB application are examples of form modules. These modules are saved with extension .frm. These modules have two views design view and code views. ii) Standard module: A module that has no user interface and is used to group certain common/global procedures or declarations is a standard module These modules are saved with extension .bas iii) Class module: A module that is used to create a user-defined data-type that can have properties, events, general procedures etc. associated with it. These modules are saved with extension .cls 3. What are data-aware controls? Name any two ActiveX data-aware controls that can be used on a form. Ans. A data aware control is a control that can provide access to a data column (or columns) of a data source, through a data control. Some intrinsic data aware controls that can be used on a form are: checkbox, textbox, image etc 4. Explain the term ADO object model. Differentiate between the Connection Timeout and Command Timeout properties of the Connection object. Ans. ADO expands to ActiveX Data Objects. It is an application program interface from Microsoft, which is used with Windows applications to get access to relational as well as non-relational databases

Connection Timeout: determines how long to wait to establish a connection. This property is used to set or return a long value that indicates, in seconds, how long to wait for the connection to open. Default is 15 seconds Connection timeout: determines how long to wait while executing a command. This property is used to set or return a long value that indicates, in seconds, how long to wait for a command to execute. Default is 30 seconds 5. How many values(s) does a procedure and a function return? Ans. A procedure returns no values whereas a function returns one value. 6. Distinguish between single document interface and multiple document interface. Write one example each of SDI and MDI type application. Ans. SDI supports single document in its window i.e., the moment a new document is opened, the previously opened document is closed and then the new document is loaded in the window. Ex notepad, wordpad MDI allows us to display multiple documents at the same time, with each document opened in its window. Ex MS-Word, MS-Excel 7. What is selection statement? Name any two selection statements that VB provides? Ans. A selection statement is the one that lets us select one course of action from the given alternatives depending upon a condition-test. VB provides two selection statements: if then else and select case 8. What are events? What are event procedure? How are they related? Ans. Events are activities that takes place either due to use interaction or due to some internal changes e.g, click event or text of a textbox changes An event procedure is a procedure containing code to be executed for a specific event. Event procedures are executed when the corresponding event gets fires. 9. What is a bound control? Name any two data aware properties to bound controls. Ans. A bound control is connected (or bound) to a database column through intrinsic data controls or any other data access mechanism. A bound control is also known as data-aware control. Two data-aware properties of bound controls are: data source and data field. 10. Write one difference and one common characteristic between a control and a variable in VB. Ans. Difference: Controls react to their corresponding events whereas variables do not have any events. Similarity: Both control and variables occupy some space in memory. 11. Why do we write comments in a program? What are the two ways of writing comments in VB? Ans. We write comments for documentation purpose as well as for future references. We write comments in VB by i) using single quote() before comment

ii) using keyword REM before comment 12. Write the purpose of select case statement with the help of an example. Which VB statement can be used in place of select case statement ? in the select case statement, what happens if every case fails and there is no case else option. Ans. Select case handles multiple-choice conditions better than if else. The select case statement can be used when multiple if statements become messy and difficult to read Eg. Select case round(avg) Case is=100 Grade=A Case 75 to 99 Grade=B Case <50 Grade=E End select If..else..endif, statement can be used in place of select-case In select case, if every case fails and there is no case else option, then nothing will be executed from the select case 13. What is the difference between a function and a sub procedure? Write one example of each. Ans. Eg. Of function Private function Test(num as integer) as integer Test=num * 2 End function Eg of procedure Private sub UseTest() Dim result as integer For i=1 to 5 Result=result+Test(3) Next Msgbox result End sub 14. What do you understand by the term Event Driven Programming? Explain Ans. Events are activities that take place either due to use interaction or due to some internal changes e.g, click event or text of a textbox changes The event driven programming style responds to such events and is driven by the occurrence of user-events. In this model whenever an event occurs a message is sent to the application informing about it, and then the application responds accordingly. 15. Write the names of any two properties and any two methods, which are common to the checkbox object and option button object.

Ans. Common properties: caption, value

common methods: setfocus, move

16. Differentiate between the DriveListBox and DirListBox. Also name the most important property of each of these controls, which needs to be set by the user. Ans. DriveListBox: displays the name of drives within and connect to PC. Its basic property is Drive, which sets the drive to be initially selected in the control or return the users selection DirListBox: displays the folders of the current drives. Its basic properties is path, which is the name of the folder whose subfolders are displayed in the control 17. What is the purpose of the common dialog control? List any two methods of the common dialog control Ans. The Windows OS uses certain standard dialog boxes to perform common activities like opening/saving/printing etc. of documents. These dialog boxes have the same interface across applications. VB applications can also make use of these standard dialog boxes by means of the common dialog control. Two methods of common dialog controls are : showsave and showcolor . 18. What do you understand by the term IDE? Why is Visual Basic called an IDE? Ans. IDE stands for Integrated Development Environment. An IDE provides different facilities such as editing, compiling, debugging etc under one roof. The working environment in VB integrates many different functions such as design, editing, compiling and debugging within a common environment. Hence, the working environment of VB is also referred to as IDE. 19. Write names of any two properties, which are common to textbox object, label object and command button? Ans. Common properties: enabled, visible 20. Differentiate between the load and show methods of a form object? Ans. Load: to load a form in memory programmatically Show: method displays a form that is currently not visible. It automatically loads the form if it is not loaded in memory already 21. What is the purpose of ADO Data Control. Name the two properties of the ADO Data Control that can by dynamically set during run-time to change the database. Ans. ADO DC is an Active X control, which works as data provider for the data bound controls and is used to display as well as manipulate database contents. Two properties of ADO DC that can be set during run time are : connectionstring, recordsourse 22. How can we break a long line of code to a new line Ans 23. Differentiate between if.then-else conditional statement support by Visual Basic, giving example Ans.

24. What are built-in function? What are different types of built-in functions of Visual Basic? Ans Built-in functions are the functions provided by a language to carry out routine tasks on built-in data-types. These functions are also called library functions. There are following types of VB functions: i) String function ii) Numeric functions iii) Date and Time functions iv) Miscellaneous functions 25. Differentiate using a suitable example between msgbox() and inputbox() functions in Visual Basic. Ans. 26. What is a syntax error in the context of a program? Give an example Ans 27. Differentiate between do while loop and do until loop of visual basic giving suitable example. Ans 28. What do you understand by the term record source of an ADO Data Control? Ans. The Recordsource refers to the source of data that the ADO DC is going to process. The Recordsouce can be a table or a query or a stored procedure. The recordsource is specified through recordsource property of ADO Data Control 29. Define the term library functions in Visual Basic. Name the different categories of library functions available in Visual Basic. Give the usage and syntax of any two library functions. Ans. 30. What are conditional or decision control statements? Name the two conditional statements used in Visual Basic? Ans. 31. Differntiate between public and private variables and discuss their scope of visibility. Ans 32. Explain the term ODBC and OLE DB Ans. Open Database Connectivity(ODBC) is an application programming interface that enables application to access data from a variety of existing data sources. OED DB is a set of interfaces that provides uniform access to data stored in diverse data stores. Using OLE DB one can access all types of databases in the same manner. 33. Differntiate between SDI form and MDI form in Visual Basic. In the similar context, explain the concept of parent and child forms. Ans. ii) in an MDI application, the parent form is the form that acts as a container for forms associated with currently open documents. A child form is one contained in the parent form. A form is made MDI child form by setting its MDIChild property to TRUE

34. What is a looping statement? Differentiate between an entry controlled and exit controlled loop. Ans. 35. Name and explain the usage of any two types of procedures available in Visual Basic. Ans. 36. What is the extension of a module file and code file in Visual Basic? Ans. 37. Explain the term ADO. Name any two methods used to navigate through ADO recordsets? Ans. 38. Name and explain the usage of any two data types used in Visual Basic to store numbers with decimals. 39.

You might also like