You are on page 1of 12

Visual Basic Programming: Introduction

Multiple Choice Questions: QNO Question 1.

Assessment
Answer Visual Basic can be used to develop applications for the following platforms (Choose

all that apply): a. Windows 95 b. Windows 98 c. Windows NT d. OS/2 e. Macintosh


2. that apply): F1 can be pressed from any context sensitive part of the Visual Basic interface to display Help information about that part. The context sensitive parts are (Choose all

a. Every window in Visual Basic (Properties window, Code window, and so on). b. Controls in the Toolbox. c. Objects on a form or document object. d. Properties in the Properties window. e. Event procedures in the Code window. 3. Microsoft Word for Windows is classified as the following type of application: a. Dialog based. b. Single Document Interface (SDI). c. Multiple Document Interface (MDI). d. Explorer e. None of the above.
4 An example of a dialog based application is (Choose all that apply): .

a. Calculator b. Notepad c. Wordpad d. Microsoft Excel e. Solitaire


5. During design time, the initial position of a form (window) can be set using the (Choose all that apply):

a. Object Browser. b. Properties Window. c. Project Manager. d. Form Layout Window. e. Initial position of a window can not be set.
6. Choose the correct answer(s).

a. All properties be set/changed during run time. b. All properties can be set/changed during design time. c. Some properties can be set/changed during design time or run time. d. Some properties are read only. e. Some properties are write only.
COMPUTER EDUCATION TECHNIQUES, INC. (VB_PRG_INTRO - 4.11) SA: Page 2

Visual Basic Programming: Introduction


QNO Question 7. Events are caused by (Choose all that apply):

Assessment
Answer

a. Mouse action. b. Keyboard action. c. Program code. d. System actions. e. None of the above.
8. Given that the txtStreet is the name of a TextBox. The statement txtStreet.Text = "19W 34th Street" can replaced with txtStreet = "19W 34th Street", because: (Choose

one)

a. A String value can be assigned to an object. b. Visual Basic can do a type conversion when appropriate. c. Text is the default property of a TextBox. d. Only first statement is legal. e. Only the second statement is legal. 9. An event procedure has been triggered by the click event of object named Obj1. What is the name of the event Procedures (Choose one): a. Sub Obj1.Click() b. Sub When_Obj1_Clicked() c. Sub Obj1()

d. Sub Clicked() e. Sub Obj1_Click() 10. The purpose of Option Explicit statement in General Declaration is (Choose one): a. To produce run time error when variables are not explicitly declared. b. To produce compiler error when variables are not explicitly declared. c. To make type declaration (using As reserved word) imperative. d. To make sure that variables are initialized when declared. e. To make the variables public by default. 11. By default, a variable declared without the As <type> is of type (Choose one): a. Integer b. String c. Variant d. Boolean e. Double
12. Procedure level variables are (Choose one):

a. Private to the procedure in which they appear. b. Available to all procedures in the module. d. Available to all modules. c. Always declared with Public reserved word. e. Are invalid within the procedure. 13. You can preserve the value of a local variable by making the variable: a. Static b. Public c. Private d. Dim e. Const
COMPUTER EDUCATION TECHNIQUES, INC. (VB_PRG_INTRO - 4.11) SA: Page 3

Visual Basic Programming: Introduction


QNO Question 14. Examine this code:

Assessment
Answer

[General Declarations] Public Total As Integer Function RunningTotal(AddMe) Static Total

Total = Total + AddMe RunningTotal = Total End Function Private Sub Form_Load() Total = 5 End Sub Private Sub cmdSum_Click() MsgBox RunningTotal(1) End Sub What will the message box display after the user clicks the cmdSum button three times? a. 1 b. 2 c. 5 d. 8 e. None of the above.
15. Examine the following code segment:

nCP = 200 nSP = 250 nPercentProfit = nSP nCP / nCP The value stored in nPercentProfit will be: a. 200 b. 250 c. 249 d. 25 e. 125 16. Which Visual Basic command should be used to terminate the logical Do While? Do While nResponse <> 0 nTotal = nTotal + nResponse a. End While b. FindNext c. Loop d. While End e. Next
COMPUTER EDUCATION TECHNIQUES, INC. (VB_PRG_INTRO - 4.11) SA: Page 4

Visual Basic Programming: Introduction


QNO Question 17. This code is found in the Click event of a button named Command1 on Form1:

Assessment
Answer

Private Sub Command1_Click( ) Call Form2.MySub End Sub In which two locations might you find the source code for the MySub procedure? a. General procedure of a general module. b. General procedure of Form2. c. Event procedure of Form1. d. Event procedure of Form2. e. In a DLL called Form2. 18. Which type of argument allows you to provide an arbitrary number of arguments? a. Named b. ParamArray c. Optional d. ByRef e. None of the above.
19. Difference between a Sub and a Function is:

a. A Function accepts parameters and a Sub does not. b. A Sub accepts parameters and a Function does not. c. A Sub can return a value and a Function cannot. d. A Function can return a value and a Sub cannot. e. There is no difference between a Sub and a Function.
20. FindTotal. Which one of the following statements will return the value of nTotal from the function

a. FindTotal = nTotal b. Return nTotal c. Exit nTotal. d. GoSub nTotal. e. A function cannot return a value.

21. You have suspended execution while in the Form_Load event. What two actions can you perform in the Immediate Window while in suspend mode (Choose two.)? a. Execute an ActiveX component. b. Change the value of a variable. c. Execute a private function of a standard module. d. Change the value of a property. e. None of the above.
22. apply): The advantage of using MsgBox() for displaying a message is/are (Choose all that

a. It displays modal window and users must respond to close it. b. Its appearance and fundamental features are dependent on the Operating System in use. c. Minimum coding is required to handle the user response. d. It automatically frees the keyboard. e. None of the above.
COMPUTER EDUCATION TECHNIQUES, INC. (VB_PRG_INTRO - 4.11) SA: Page 5

Visual Basic Programming: Introduction


QNO Question 23. Return value of the InputBox() function is of type (Choose one):

Assessment
Answer

a. Integer b. Currency c. String d. Boolean e. Single


24. How can you set the Default Error Trapping State?

a. Set the DefaultBreak property of the App object. b. Check the appropriate State in the Default Error Trapping submenu under the Debug menu.

c. Use the Err object during run time. d. Set the Error Trapping option button on the General tab under the Tools, Options menu item. e. None of the above.
25. How can you set an error trap?

a. Use the Resume command. b. Use the On Error statement. c. Place a Label before your error handler code. d. Write an error handling routine that responds to all errors you can anticipate. e. Use the If Error statement.
26. Examine this code:

Sub Main() On Error GoTo ErrHandler MsgBox Dir("A:TEST.TXT") MsgBox Err.Number EXIT SUB ErrHandler: Resume End Sub If the floppy drive door is open, what will happen when the application runs? a. The system locks... no error message is displayed, but the error keeps recurring. b. A message box displays that says Dir("A:TEST.TXT"). c. A Visual Basic error message is displayed that states that the GoTo statement is not supported. d. A message box that lists the Device Unavailable error number is displayed. e. None of the above.
27. number (Choose all that apply): With the Open statement, in which mode(s) can a file be opened, using a different file

a. Binary b. Input

c. Append d. Random e. Output


COMPUTER EDUCATION TECHNIQUES, INC. (VB_PRG_INTRO - 4.11) SA: Page 6

Visual Basic Programming: Introduction


QNO Question 28. The Close statement without any file number:

Assessment
Answer

a. Closes the most recently opened file. b. Closes file number 1. c. Produces a compile time error. d. Close all files. e. Produces a runtime error.
29. processed? Which VB command would be used after this code to ensure that all records are

Do While Data1.Recordset.EOF = False Data1.Recordset.MoveNext 'Process current record a. End Do b. FindNext c. Loop d. While End e. None of the above.
30. properties? When should public variables be used instead of property procedures for read write

a. The property has a well defined set of values that need to be validated. b. The property is read only. c. The property is a String data type, and there is no constraint on the the size of the string.

d. Setting the property causes changes to other internal variables or to the values of other properties. e. None of the above.
31. statements? When would the #If...#End IF and #Const directives be used to conditionally compile

a. The application will access various graphics files. b. To create Symbolic Debug Info. c. The application will run on different platforms. d. Designing an internet enabled ActiveX application. e. To check a value at run time. 32. For which control does the ImageList control act as a central repository of images? a. ListImage b. TreeView c. ListView d. TabStrip e. None of the above.
33. The To reserved word is used to:

a. Specify a range of values. b. Send data to a file. c. Send data to a print device. d. Send data to the communication port. e. None of the above.
COMPUTER EDUCATION TECHNIQUES, INC. (VB_PRG_INTRO - 4.11) SA: Page 7

Visual Basic Programming: Introduction


QNO Question 34. The SelLength property for a text box:

Assessment
Answer

a. Allows the use to entered data. b. Returns ro sets the number of characters selected. c. Specifies the maximum number of

characters that can be entered. d. a,b,c. e. Is invalid.


35. The class module Class1 contains this code:

Public Sub DivideByZero () x=x/0 End Sub A form contains this Command button click event: Private Sub Command1_Click() On Error GoTo Err Handler Dim c1 As New Class1 c1.DivideByZero MsgBox "OK" exit sub ErrHandler: Resume Next MsgBox Err.Description End Sub If the default error trapping option is set to Break in Class Module, what will happen when the Command1 button is clicked? a. A message box that displays only the description of the error will appear. b. A message box that displays only an "OK" button will appear. c. The execution of the application will be suspended without displaying an error message. d. The standard VB error message window will appear. e. The system will hang.
COMPUTER EDUCATION TECHNIQUES, INC. (VB_PRG_INTRO - 4.11) SA: Page 8

Visual Basic Programming: Introduction


Multiple Choice Questions: QNO Question 36. a. TRUE b. FALSE 37. Programs created with Visual Basic Version 5 can run in OS/2 environment.

Assessment

Answer

Visual Basic Developers Studio allows you to compile multiple projects into one

application.

a. TRUE b. FALSE 38. The Startup object of a project can be a Form or Sub Main(). a. TRUE b. FALSE 39. Multiple controls on the same form can have the same name. a. TRUE b. FALSE 40. Only one Command Button on a form can have the Cancel property set to True. a. TRUE b. FALSE
41. A Combo Box doesn't have the MultiSelect property.

a. TRUE b. FALSE
42. a. TRUE b. FALSE 43. project. A variant type variable can store a date value.

Scope of a variable declared in the general declaration of a form module is the entire

a. TRUE b. FALSE
44. a. TRUE b. FALSE 45. under different Operating Systems. a. TRUE b. FALSE 46. A variable declared without a specific type is of string type by default.

A dialog box displayed by CommonDialog control can have different appearance

An Event Procedure can be called from another Sub

procedure or a Function procedure. a. TRUE b. FALSE

COMPUTER EDUCATION TECHNIQUES, INC. (VB_PRG_INTRO - 4.11)

SA: Page 9

Visual Basic Programming: Introduction


QNO Question 47. loaded with Load Form1 statement. a. TRUE b. FALSE 48. reserved words are ByRef by default. a. TRUE b. FALSE 49. number to the file opened. a. TRUE b. FALSE 50.

Assessment
Answer The Form1.Show statement will Load and Show Form1 even if the form hasn't been

Parameters of a Sub Procedure or a Function, declared without the ByVal/ByRef

FreeFile reserved word can be used with Open statement to assign the next available

The following statement will write the contents of variables sCity, sState and sZip separated by tabs in file #2: Print #2 , sCity, Tab(1), sState, Tab(2). sZIP.

a. TRUE b. FALSE

COMPUTER EDUCATION TECHNIQUES, INC. (VB_PRG_INTRO - 4.11)

SA: Page 10

You might also like