Visual Basic MCQs

Visual Basic MCQs

Try to answer these 100+ Visual Basic MCQs and check your understanding of the Visual Basic subject.
Scroll down and let's begin!

1: If, Then, Else are examples of:

A.   variables

B.   events

C.   conditionals

D.   operators

2: Which of the following, when inputted into the command prompt, will successfully launch the Visual Basic script file_name.vbs?

A.   All of these are correct

B.   wscript file_name.vbs

C.   cscript file_name.vbs

D.   Pressing enter after you write: file_name.vbs

3: Visual Basic 6.0 has been replaced by:

A.   VB.NET

B.   Visual Studio

C.   Visual C++

D.   C++

4: The three types of Visual Basic operators are:

A.   arithmetic, relational, and logical

B.   plus, minus, multiply

C.   divide, multiply, plus

D.   add, divide, multiply

5: Visual Basic can do which of the following?

A.   Develop Windows applications

B.   Create executable files (EXE files)

C.   All are correct

D.   Create DLL files

E.   Create ActiveX controls

6: Visual Basic applications display a Windows style screen called a form.

A.   True

B.   False

7: When you save a project as an executable file, you are actually:

A.   deleting

B.   decompiling

C.   compiling

D.   coding

8: LoadPicture is a function of an Image control that can:

A.   format the border of the image

B.   change the color of the image

C.   delete an existing picture

D.   populate the picture with an image from a specified directory

9: A variable can be assigned a value.

A.   False

B.   True

10: Which character must be placed at the beginning of a line to indicate that it is a comment (not considered part of the code)?

A.   "

B.   #

C.   +

D.   -

E.   '

11: To declare a variable in Visual Basic, you must use the ___________ function:

A.   Dim

B.   Loop

C.   Declare

D.   Private Sub

12: The code to cancel out of a Loop event is:

A.   Clear

B.   Cancel

C.   Exit Do

D.   Delete Loop

13: What is the proper syntax for adding items to a listbox?

A.   listbox.setnewitem = item

B.   listbox.newitem.add(item)

C.   listbox.items.item(item).register

D.   listbox.items.add(item)

E.   listbox.itemmenu.add(item)

14: The default file type for a Visual Basic project is:

A.   .vbo

B.   .mvb

C.   .frm

D.   .vbp

15: How to declare a variable in VB?

A.   All of these

B.   Dim (Variable) AS (Datatype)

C.   Declare @(Variable) (Datatype)

D.   (Datatype) (Variable);

16: What keyword(s) end every procedure

A.   Stop

B.   End

C.   End Sub

D.   Stop Procedure

E.   Ending

17: Press _________ to run a program.

A.   F5

B.   F4

C.   F7

D.   F6

18: Which control can be data bound?

A.   Label

B.   Textbox

C.   Checkbox

D.   All of these

19: Visual Basic is an ____________ driven language.

A.   event

B.   assembly

C.   adjective

D.   asp

20: What keyword starts every procedure?

A.   For

B.   Begin

C.   Start

D.   Sub

E.   With

21: Visual Basic is derived from:

A.   C++

B.   BASIC

C.   Qbasic

D.   Assembly

22: Once you complete a program, you can compile it into a _________ file.

A.   .exe

B.   .vb

C.   .vbp

D.   .html

23: To create a function that returns a value you must use a:

A.   none of these

B.   sub

C.   procedure

D.   function

24: How do you enter in comments without having an output?

A.   */

B.   @

C.   '

D.   %

E.   %%

25: To show a form, use the ____________ command.

A.   visible

B.   appear

C.   display

D.   show

26: The programmer can enter, edit, and view the language of Visual Basic in the:

A.   document

B.   form explorer

C.   project explorer

D.   code window

27: The Enterprise Edition of Visual Basic is aimed at:

A.   C++

B.   network oriented clients

C.   file sharing

D.   decompiling

28: Integer is an example of a:

A.   variable

B.   data type

C.   number

D.   procedure

29: Visual Basic is considered a ___________ programming language.

A.   high level

B.   mid-level

C.   assembly level

D.   low level

30: The '&' symbol is the safest _________ operator to use in Visual Basic.

A.   Relational

B.   Boolean

C.   Arithmetic

D.   Concatenation

31: What is MAPI ?

A.   Messaging Application Programming Interfere

B.   Messaging Application Programming Interface

C.   None of the Above

D.   Messaging Administration Programming Interface

E.   Messaging Application Programming Interchange

32: Can you access and modify the Windows Registry by using VB Scripting?

A.   No

B.   Yes

C.   You can read but cannot write

33: How do you prevent the screen from flickering while running a macro?

A.   Application.ScreenUpdating = True

B.   Application.ScreenUpdating = False

C.   Application.Visible = True

D.   Application.DisplayAlerts = False

E.   Application.Visible = False

34: B=2 C=3 What does A=B=C output?

A.   6

B.   True

C.   False

D.   2

E.   3

35: What code will adjust the Zoom Level on a worksheet in Excel to 80%?

A.   ActiveWindow.Zoom = 80

B.   ActiveWindow.Zoom = -20

C.   ActiveWindow.Zoom.Adjust = 80

D.   Application.Zoom = 80

E.   Zoom = 80

36: What type of executable can VB6 not produce?

A.   Standard EXE

B.   Native DLL

C.   ActiveX EXE

D.   ActiveX Control

E.   ActiveX DLL

37: MDI is an IDE developed by Microsoft and stands for:

A.   Microsoft Data Interface

B.   Multiple Data Interface

C.   Multiple Document Interface

D.   Microsoft Document Interface

38: What keyword ends a For loop?

A.   Done

B.   Next

C.   End

D.   End Loop

E.   End For

39: Lower bound of arrays in VB 6 is

A.   1

B.   Determined by a compiler switch

C.   Default is 0. Can be set to 1 by "Option Base 1"

D.   0

E.   Default is 1. Can be set to 0 by "Option Base 0"

40: What is the difference between LockPessimistic and LockOptimistic ADO locking types.

A.   LockPessimistic Locks the row automatically. LockOptimistic Locks the only when initiated by code.

B.   There is no difference

C.   LockPessimistic Locks the row once after any edits occur. LockOptimistic Locks the row only when Update is called.

D.   LockPessimistic Locks the row only when Update is called. LockOptimistic Locks the row once after any edits occur.

41: Which of the following is a correct example of Windows API import declaration in VB6

A.   Public External Sub RtlMoveMemory Lib "Kernel32" (lpvDest As Any, lpvSource As Any, ByVal cbCopy As Long)

B.   Import Function "RtlModelMemory" Alias "CopyMemory" From "Kernel32" ([Pointer] lpvDest As Any, [Pointer] lpvSource As Any, ByVal cbCopy As Long)

C.   Import Function "RtlModelMemory" As "CopyMemory" From "Kernel32" (lpvDest As Any, lpvSource As Any, ByVal cbCopy As Long)

D.   DllImport Sub CopyMemory From "Kernel32" Original "RtlMoveMemory" (lpvDest As Any, lpvSource As Any, ByVal cbCopy As Long)

E.   Private Declare Sub CopyMemory Lib "kernel32" Alias "RtlMoveMemory" (lpvDest As Any, lpvSource As Any, ByVal cbCopy As Long)

42: What does Option Explicit refer to?

A.   All variables must be declared before use. Their type is not required.

B.   variables are defined automatically

C.   All variables with their types must be declared before use.

D.   Options for all built in controls is restricted.

43: What is the max size allowed in characters for Msgbox Prompt and Input Box?

A.   1024

B.   512

C.   2048

D.   256

E.   780

44: Dim x, y as integer. What is x and y data type?

A.   x as variant and y as integer

B.   Both are integers

C.   Wrong declaration

45: Which of the following is NOT the value of StartUpPosition property in Visual Basic 6?

A.   1 - CenterOwner

B.   0 - Manual

C.   3 - Windows Default

D.   2 - CenterScreen

E.   4 - Automatic

46: True or False? In Visual Basic 6, to enable automatic re-painting of MDI Form, we have to set AutoRedraw=True

A.   False

B.   True

47: To debug VB 6 applications with source code using a native debugger like Visual Studio, one must

A.   "Compile to Native Code" and enable "Create Symbolic Debug Info"

B.   select "Start with Full Compile" from "Run" menu

C.   add "NATIVE=1:DEBUG=1" to "Conditional Compilation Arguments"

D.   "Compile to P-Code" and enable "Create Symbolic Debug Info"

E.   Attach to VB6.exe from Visual Studio

48: In Visual Basic 6, How will you disable/hide the control box on a form?

A.   Using Windows API

B.   By Setting ControlBox Property to False or by using Windows API

C.   By Setting ControlBox Property to True

D.   By Setting ControlBox Property to False

E.   By Passing parameter FALSE to Forms SHOW Method

49: Which one of the following property pages is not provided by Visual Basic 6

A.   StandardColor

B.   StandardPicture

C.   StandardLayout

D.   StandardFont

E.   StandardDataFormat

50: How do you make a property default in VB 6?

A.   Decorate it with "<Default>" attribute

B.   You can not

C.   Rename your property to "Default"

D.   Using "Option Default Property 'propertyname'" in "General Declarations" section

E.   Set "Procedure ID" property of property to "(Default)" in "Procedure Attributes" dialog

51: What two methods are called from the ObjectContext object to inform MTS that the transaction was successful or unsuccessful?

A.   TransactionSucess and TransactionFail

B.   ObjTransOk and ObjTransFail

C.   SetComplete and SetAbort.

D.   ObjectComplete and SetObject

52: What is the correct entry:

A.   Dim s:=2

B.   Dim s : s=2

C.   Dim s=2

D.   Dim s:2

53: For Excel, what is the shortest code that would change the column width of columns L & X to 30?

A.   Columns("L:X").Width= 30

B.   Select("L:L,X:X").ColumnWidth= 30

C.   Range("L:X").ColumnWidth= 30

D.   Range("L:L,X:X").ColumnWidth= 30

E.   Columns("L:L,X:X").Width= 30

54: For Excel... What is the shortest code that would AutoFit all rows in the active worksheet?

A.   ActiveWindow.Cells.Rows.AutoFit

B.   Cells.EntireRow.AutoFit

C.   ActiveWorkbook.EntireRow.AutoFit

D.   ActiveWorkbook.Rows.AutoFit

E.   Rows.AutoFit

55: Which one of the following cannot be added to a UserControl in VB6

A.   Timer Control

B.   Another UserControl

C.   OLE Control

D.   An OCX Control

56: When an ActiveX project is compiled, its COM interface can be preserved by using Binary Compatibility. Between compilations VB creates different interfaces for modified parts of classes. This is called:

A.   Assume No Aliasing

B.   Interface Forwarding

C.   COM Compatibility

D.   Retained in Memory

E.   Out of Process Library

57: In Visual Basic 6, which one is NOT a parameter of connection objects open method?

A.   Options

B.   Source

C.   UserID

D.   Connection String

E.   Password

58: To make a UserControl transparent

A.   Set Opacity to 0

B.   Set BackColor to Transparent

C.   Add WindowStyle VB_TRANSPARENT

D.   Set Transparent to True

E.   Set BackStyle to Transparent

59: KeyDown is an example of a:

A.   command

B.   executable

C.   function

D.   procedure

60: Which property is required to place a control on Visual Basic 6 MDI Form?

A.   Align Property

B.   AutoRedraw Property

C.   DrawMode Property

D.   IsParent Property

E.   IsChild Property

61: What is the numeric value for the boolean "True"?

A.   1 byte

B.   0

C.   1

D.   -1

62: What is the window class of a debugged MDI application in VB6

A.   VBFormMDI6

B.   ThunderMDIForm

C.   VBFormMDI

D.   ThunderMDI6Form

E.   VB6MDIForm

63: What command line argument is passed to an out of process COM server to register it

A.   DllSelfRegister

B.   regserver

C.   regsvr32

D.   regsvr64

E.   register

64: For Excel, what will the following code do? Range("A2").Select: ActiveWindow.FreezePanes = True

A.   Freeze Column A

B.   Freeze Panes will not work with that range selected

C.   Freeze Row 1

D.   Remove current Freeze Panes settings

E.   Freeze Column A & Row 2

65: How do you bold an output text?

A.   text.selbold=true

B.   select.bold=true

C.   .bold=true

D.   .SelBold=true

E.   text.bold=true

66: What is the maximum value of the Interval Property for a timer?

A.   128 seconds

B.   60 seconds

C.   1.4 seconds

D.   10 seconds

E.   65.5 seconds

67: You have to parse all the rows in a ListView control. What is the correct statement?

A.   for i=1 to ListView1.ListItems.Count

B.   for i=0 to ListView1.ListItems.Count - 1

C.   for i=0 to ListView1.ListItems.Count

A.   No

B.   No, but use workarounds such as: GetQueueStatus or GetInputState APIs

C.   Use a timer instead of loop

D.   No, but use workarounds such as: Timer, GetTickCount API

E.   Yes

69: ____ error messages indicate coding errors detected by the compiler.

A.   ​Run

B.   ​Compile

C.   ​Build

D.   Executable

70: A ____ is an item that is a visible part of a gui.

A.   Property

B.   Class

C.   Control

71: A ____ is the general shape of the characters in the text.

A.   Font

B.   Format

C.   Solution

D.   Text

72: A class ____ is a collection of classes that can be made available for developers to use.

A.   ​title bar

B.   ​library

C.   ​controls

D.   ​logical

73: A class-level variable ________.

A.   All the three choices here. (is declared inside a class but outside any procedure, is accessible to all procedures in a class, is visible to all statements inside the class)

B.   Assigning the predefined constant String.Empty to the text property

C.   Both a date and a time

D.   No value is returned. A runtime error is generated

74: A form’s ____ property specifies the text that appears in the form’s title bar.

A.   Caption

B.   Values

C.   Label

D.   Text

75: A module-level variable declared public is also known as a __________ variable.

A.   Private

B.   Access

C.   Global

D.   Universal

76: A sub procedure ____ argument(s).

A.   Cannot accept any

B.   Can accept two

C.   Can accept one

D.   Can accept any number

77: Another term for a selection structure is a ____ structure.

A.   Concatenation

B.   Relational

C.   ToLower

D.   Decision

78: Arguments are contained inside ____ after the name of the procedure to be called.

A.   Braces

B.   Brackets

C.   Parentheses

D.   Quotation marks

79: Arrays that are ____ can be resized at run time.

A.   Static

B.   Noninteractive

C.   Dynamic

D.   Parallel

80: Comparison operators are also referred to as ____ operators.

A.   Concatenation

B.   Relational

C.   Decision

D.   Boolean

81: In a case selection structure, you use the ____ keyword when you know only one end of the range.

A.   From

B.   To

C.   Is

D.   Range

82: In microsoft visual basic, use the ____ statement to create a string variable.

A.   Var

B.   Decl

C.   Declare

D.   ​Dim

83: In the code editor, ____ is used to indicate the location of an error.

A.   Comment

B.   A blue squiggly line

C.   Equal sign (=)

D.   Error List

84: The color of the text in a label control is determined by the ________ property.

A.   Color

B.   Font

C.   ForeColor

D.   TextColor

85: The select case statement ends with the ____ clause.

A.   RadioButton

B.   Seven

C.   Nested selection structure

D.   End Select

86: You create a named constant using the ____ statement.

A.   Const

B.   Comment

C.   Input

D.   Controls

87: You declare a class-level variable using the ____ keyword.

A.   Private

B.   Dim

C.   Mod

D.   Static

88: String variables are automatically initialized using ____.

A.   Declare variables for all of the input data

B.   Advance the insertion point to the next line in a control

C.   Decimal.TryParse(txtLateFee.Text, decLateFee)

D.   The keyword Nothing (no data at all

89: The ____ indicates that a statement is an assignment statement.

A.   Keyword Assign

B.   Ampersand (&)

C.   Equal sign (=)

D.   Keyword Set

90: The ____ method returns an integer that represents the location of the substring within the string.

A.   WriteLine

B.   IndexOf

C.   BindingSource

D.   PadRight

91: The ____ of a programming language is the set of usage rules for that language.

A.   Use case

B.   Syntax

C.   Label

D.   Toolbox

92: The ____ of a variable is defined by where it is declared within a program.

A.   False

B.   Counter

C.   Scope

D.   True

93: The ____ of a variable specifies where a variable can be referenced within a program.

A.   Range

B.   Scale

C.   Lifetime

D.   Scope

94: The ____ property of a control is used to specify the position of the text within the control.

A.   AlignText

B.   Alignment

C.   TextAlign

D.   Justify

95: The ________ control uses a label to display program status information and messages to the user.

A.   LinkLabel

B.   StatusStrip

C.   ErrorProvider

D.   TextBox

96: The ________ operator performs division and returns the remainder.

A.   Modulus %

B.   Division /

C.   Multiplication *

D.   None of the above

97: The ________ operator performs string concatenation.

A.   Ampersand (&)

B.   Dollar sign ($)

C.   Percent symbol (%)

D.   Pound symbol

98: The assignment operator in visual basic is the ____ symbol.

A.   1/1/0001 12:00:00 AM

B.   _ (underscore)

C.   =

D.   Advance the insertion point to the next line in a control

99: The contents of a text box may be cleared in visual basic code by ________.

A.   Assigning the predefined constant String.Empty to the text property

B.   I = P x ( Y x ( B * 1 - A) )

C.   LblTotalSold.text = intQuantity.ToString()

D.   LblTotalSale.text = decTotSale.ToString(

100: The entries in a listbox are stored in the __________ property.

A.   Items Count

B.   Items

C.   Entries

D.   Text