Visual Basic - Test 1
No. of Questions - 20
Time - 40 Minutes
Negative Marking- No

 

Question 1. 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 Go To 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.

Question 2.

What can you use to modify the definition of a procedure in a class module to make the procedure callable from modules outside the class, but only those that are part of the project where the class is defined?

A.   Private
B.   Friend
C.   Public
D.   Static

Question 3.

You have written code in a Mouse-Up Event of a ListBox to active the mnuVendor context menu when the user right-clicks an item. You leave the Visible CheckBox for the mnuVendor menu unchecked.
How will this affect the display of the application’s menu?

A.A Separator Bar will be displayed in the menu where the now invisible Vendor menu          item would have displayed.
B.Menu items below the invisible menu item "move up" in the menu to fill the empty       space.
C.Your PopupMenu command to display that top-level menu will not work.    
D.The only way to display that menu item is to first set it’s Visible property back to        True.
Question 4. Examine this code:

Sub Main()
On Error GoTo ErrHandler
MsgBox Dir(A:TEST.TXT")
MsgBox Err.Number
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.

Question 5. 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.
Question 6.
  1. Examine this code:

    [General Declarations]
    Function Squarelt(num)
    TempVal = Abs(num)
    Squarelt = Sqr(TmpVal)
    End Function

    Private Sub cmdTest_Click()
    MsgBox Squarelt(2)
    End Sub

What happens when the user clicks cmdTest?

A.   A message box showing 4 is displayed.
B.   A message box showing 0 is displayed.
C.  An error occurs because Squarelt() is out of scope.
D.   An error occurs because the variable TempVal is misspelled.

Question 7. Which Key’s Value will be saved to the Registry with this SaveSetting statement?
SaveSetting "Hydra", "Startup", "Backup", strDate

A.   "Hydra"
B.   "Startup"
C.   "Backup"    
D.   strDate
Question 8. You are adding an Edit menu named mnuEdit to your application so that your users will be able to Cut, Copy and Paste data in text fields. The user selects a section of text, and cuts it to the Clipboard. Which command will dynamically dim the mnuEditCopy menu item?

A.   MnuEdit.Disable( mnuEditCopy ) = True
B.   MnuEditCopy.Disabled = True
C.   MnuEditCopy.Enabled = False
D.   MnuEditCopy.Dim

Question 9. Which code adds the column "Author" to a ListView named IvwData?

A.   IvwData.Column.Add, "Author"
B.   Add IvwData.ColumnHeaders, "Author"
C.  IvwData.Add( Column, "Author")
D.   IvwData.ColumnHeaders.Add, , "Author"
Question 10. You are creating an application that allows asynchronous communication between its server and client objects. You want the server component to be able to prioritize its notifications in order to control which client object receives notification first.

Which technique would you use to implement this design?

A.   Polling
B.   MSComm
C.  Events
D.   Call-backs

Question 11. How can you access items in a Buttons collection?

A.   Execute its Getltem method
B.   Reference its index or unique key
C.      Manipulate its Tag property
D.   Set a Field object to point to the item.

Question 12.

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.

Question 13. Which debugging tool allows you to execute code or query values while the application is in break mode?

A.   Locals Window
B.   Immediate Window
C.   Watch Window
D.   Query Window

Question 14. How many instances of Visual basic are necessary to debug an out-of-process component?

A.   0
B.   1
C.   2
D.   3

Question 15. Which StatusBar property allows the display of common data such as date, time, and keyboard states?

A.   Text
B.   Style
C.   Object
D.   Simple Text

Question 16.

You want to refer to the contents of the child of the selected node of a TreeView namedTreeView1.

Which expression would you use?

A.   nodChild = TreeView1.Nodes(SelectedItem).Child
B.   nodChild = TreeView1.Child
C.   Set nodChild = TreeView1.Nodes(Treeview1.SelectedItem.Index).Child
D.   Set nodChild = TreeView1.Nodes(Treeview1.SelectedItem).Child

Question 17. Which two techniques can be used to create a control array?

A.   At design time, assign the same name to more than one control
B.   At run time, assign the same name to more than one control
C.  At run time, set the control’s Index property to a value that is not Null.
D.   Use the Control() function

Question 18. In which two situations would you load, but not show, a form?

A.   to access records in a MS Access database
B.   to use a common dialog control
C.   to use the Timer control to generate timed events
D.   to start an Error Handler routine

Question 19. You are creating an application that will save a list of most recently opened files at the end of its File menu. What should you use to store this list of files?

A.   menu control array
B.   menu Editor
C.   menu Item Collection
D.   array of file names created with the Dim command
Question 20. When would you use the #If…#End IF and #Const directives to conditionally compile statements?

A.   Your application will access various graphics files.
B.   You want to create Symbolic Debug Info
C.  Your application will run on different platforms
D.   You are designing an internet-enabled ActiveX application.

answers     scores