Elance VBA Test Answers 2015
·
What does VBA mean?
Visual Basic for Applications
Visual By Arithmetic
Visual Basic Answers
Visual By Algorithms
Using the Select Case construct is ideal when:
An action is taken regardless of the value a
variable
A variable can take on multiple values
A variable is a Boolean type
Too many if-then statements have already been used
The tab order in a user form:
________ is a way to control the order in which the
controls are selected using the TAB key.
Requireing the user to assign numbers to each
control on the user form
Arranging the worksheets in an Excel workbook
Allowing the controls to be sorted alphabetically
within the user form
The RowSource property of a Combo Box control
allows the user to:
control where the output of selected item should go
define the list of items, from a range of cells, to
appear in a drop-down list
restrict which row of cells can be the source of
input items for the drop-down list
have only one item in the drop-down list
Choose the VBA code that will allow you to
obtain information about an error.
Err.Name
Err.Type
Err.Description
Err.Title
To save a VBA project with an Excel workbook,
the workbook must be saved as what type of file?
xlsv
xlv
xlsm
xlsx
You can use VBA to connect to a database in
SQL Server using:
an ADODB.Connection
Access as a go-between
Just a simple SQL statement
an ethernet cable
On July 4, 2013, What will be displayed in the
message box from the following statement:
MsgBox(Format(Now,"mm-dd-yyyy"))
7/4/2013
07-04-2013
07/04/2013
7-4-2013
Which of the following do not work on Excel on
Mac
ActiveX Controls
Form Controls
Which of the following would you begin a
comment line with?
Equal sign
Double quote
Underscore
Single quote
What is difference between a sub routine and a
function.
Sub routine can return a value.
Function can return a value.
Which of the following snippets of VBA code is
not a loop?
Do Until... Loop
Select Case... Case... Case Else... End Select
Do While... Loop
For Each.. Next
What does VBA stand for
Very Basic Applications
Visual Basic Applied
Virtual Basic for Advanced programming
Visual Basic for Applications
What is a macro used for?
To link Excel files together
To automatically complete a series of Excel steps
To create buttons and forms in Excel
To access programs in Excel
To comment a block of code, you must first:
Turn on Caps Lock
Activate the Edit toolbar in the Visual Basic
Editor
Turn on Num Lock
Restart Excel
How do you declare the variable myvar as an
integer?
Dim myvar As Integer
Declare myvar is an Integer
Document myvar as an Integer
The 'not equal to' operator is:
<>
==
>=
<=
To continue to run code even if a line of code
causes an error, choose the VBA code to continue to the next line of code.
On Error Resume
Goto
On Error Resume Next
Next
To force all variables is a VBA project to be
declared, which must be stated in a module?
Option Implicit
Option Explicit
Option Declare
Option Variables
True or False? Commenting at the end of a line
of code is permissible.
True
False
What do you need to select to set the
developer mode?
Show mini toolbar on selection
Show developer tab in the Ribbon
Show macro code settings
Show visual basic options menu
True or False? It is possible to name a Sub
with a string containing a space.
True
False
Which of the following is not a VBA data type?
VarChar
Integer
String
Long
Date
To obtain the value of the number of
characters used in a textbox field on a form, which snippet of VBA code would
you use?
Char(Forms!DataEntryfrm.Text11.Value)
Spaces(Forms!DataEntryfrm.Text11.Value)
Length(CStr(Forms!DataEntryfrm.Text11.Value))
Len(CStr(Forms!DataEntryfrm.Text11.Value))
You've created a user form named 'Entry_Form'.
To make the user form appear, use which of the following statements?
Entry_Form.Show
Entry_Form.Appear
UserForm.Load
UserForm.Entry_Form.Run
The shortcut keystroke to open the VBA IDE is:
Alt+V
F10
Alt+Ctrl+F8
Alt+F11
Is it possible to create an array with the
lowerbound being two?
Sometimes
No
Yes
Correct this statement to start a 5-iteration
loop: For x = 1 to 10 Step -2
For x = 1 to 10 Step 2
For x = 1 to 10 Step 5
For x = 1 to 5 Step 2
For x = 1 to 5 Step 5
Which of these is not a Visual Basic object?
Range
Sheets
FontSize
Selection
What does a VBA macro consist of?
User instructions and Excel functions
Computer code that performs some actions on or with
objects
Macro instructions that direct the user application
and provide help to the user
Excel functions
Declaring a public variable allows the user
to..
Use the variable as a named range in Excel
Use the variable only within the module in which
the variable was declared
Use the variable anywhere in Excel
Use the variable anywhere in the project in which
the variable was declared
Which worksheet event can be used to run a
procedure upon deleting the contents of a cell?
Change
Click
Calculate
Activate
How do you figure out the number of items in a
collection?
(none of these are correct)
Using Ubound property
Using Count property
Using Items property
Using Contains method
Which of the following VBA windows shows the
code of the active object?
Immediate window
Properties window
Code window
Explorer Window
In the statement x = "4" +
"5"', x = ?
1
45
-1
9
What is the shortcut keystroke to debug VBA
code one line at a time?
Alt+F5
F5
Ctrl+F8
F8
The way to pass the latest values of variables
between functions and procedures is identified as:
ByChange
ByUpdate
ByRef
(none of these)
Which of these statements will start a loop of
exactly 20 iterations?
For i = 1 to 21
For i = 2 to 22
For i = 2 to 40
For i = 2 to 40 Step 2
Dim a,b as integer What is the type of a?
variant
integer
What is the difference between activating and
initializing a user form?
Initialize will always run when showing a user form
whereas Activate will only run when showing a user form that has not been
stored in memory.
Activate will always run when showing a user form
whereas Initialize will only run when showing a user form that has not been
stored in memory.
There are no differences. Both are run whenever a
user form is shown.
There are differences only if Option Explicit is
stated.
The statement 'Dim a, b as Single' declares
the variables a and b as what variable types?
a as Single; b as Single
a as Double, b as Single
a as Double; b as Double
a as Variant; b as Single
What is the property of a cell that allows you
to set the font color of the contents?
Font.Color
CellColor
Cell.Color
FontColor
Choose the VBA code that switches control from
the application to the OS.
DoEvents
Continue
Wait
Goto
What does the DoEvents do?
Declare a new event that can be fired from code
Allows operation system to process other events
Runs all events (built-in or custom) in a vb
project
Runs all Excel events in a vb project
If you want to create a definition for a
custom object in VBA, which of the following would be the best choice to insert
into your project?
UserForm
Module
Class Module
Procedure
Which of the following functions do not
perform a calculation
Val
IPmt
Exp
Sqr
To change a comment in cell A1, which will do
the job?
Range("A1").Comment("My
Comment")
Range("A1").Comment.Text("My
Comment")
Range("A1") = "My Comment"
Range("A1").Text("My Comment")
Combine into one line: If x > 5 Then y = x
- 5 End If
y = x - 5 If x > 5
If x > 5 Then y = x - 5
If x > 5, y = x - 5
If x > 5 Then y = x - 5 End If
Which code will allow user to edit a password
protected worksheet.
Sheets("Sheet1").Unprotect
Sheets("Sheet1").Unlock
Password:="Password"
Sheets("Sheet1").Unprotect
Password:="Password"
Sheets("Sheet1").Edit
Password:="Password"
Sheets("Sheet1").DisableProtect
Password:="Password"
To change the text displayed in a label on a
form, choose the VBA code that will allow you to update the property.
Me.Label3.Text = "Hello"
Me.Label3 = "Hello"
Me.Label3.Value = "Hello"
Me.Label3.Caption = "Hello"
Which of the following actions will NOT cause
a macro to run in Excel?
Add a new worksheet
Click on a picture
Open a workbook
(all of these will NOT cause a macro to run in
Excel)
When stepping through code as a way to see how
the values in variables change, use the:
Watch Window
Locals Window
Immediate Window
Variables Window
Choose the VBA code that will allow you to
verify that an Item exists in the Dictionary object Dict1.
If xDict1.Key("Testing")
If xDict1.Exists "Testing" Then
If xDict1.Exists("Testing") Then
If xDict1.Item("Testing") Then
What value is x holding after this statement
is executed: x = Left("Apple",3) & Right("People", 3)
ApplePeople
Appple
AppPeo
Apple
Month(#12/25/02#) will output?
December
#12
#12#
12
#December
'Do While x < 5' is equivalent to:
Do While x > 5
Do Until x >= 5
Do While x <= 5
Do Until x > 5
What will Format(2.36, “#0.0”) output?
"#2.36"
"#2.4"
"2.3"
“2.4”
"#.36
You have written a function called Switch
requiring the input string parameters a and b. The function will concatenate
the values assigned to b and a, in that order. What line of code is needed
within the function?
Switch = "b" & "a"
Switch = ba
Switch = b & a
Switch = b, a
The library to make ADODB.connection work.
Microsoft Active X Data Objects
Microsoft Active X Data Objects Recordset Microsoft
ADO for DDL and Security Microsoft Add-Inn Designer MIcrosoft OLAP Designer
Server Driver
In the next statement: "Dim bValue as
Boolean" What will be the default value for "bValue" variable?
Null
Undefined
True
False
Blank
What is the right syntax to raise your custom
error?
Cannot raise custom error
Err.Raise Number:=999, Description:="My custom
error"
RaiseError Number:=999, Description:="My
custom error"
Error.Raise Number:=999, Description:="My
custom error"
Under which menu option in the VBA IDE can you
password protect a VBA project?
Tools>References
Tools>Protection
Tools>Options
Tools>VBAProject Properties
You want to count how many records for a given
customer based on CustomerID which is of field type short text in table
tblCustomer. The customer id we want the count for is 123-AC. We are using the
domain aggregate function DCount and assign it to an integer variable intC what
is the correct syntax.
intC = DCount ("*","tblCustomer","[CustomerID]
= ' & 123-AC & "'")
Syntax is incorrect can't save in an integer
variable if you are counting on a field type of short text.
intC =
DCount("tblCustomer","*","Me.CustomerID =
123-AC")
intC=DCount("123-AC","tblCustomer","[CustomerID]")
intC =
DCount("*","tblCustomer","[CustomerID] = " &
123-AC)
What is BOF?
A property of the Recordset object.
All answers are correct.
A property of the Document object.
Choose the VBA code to execute a Word
MailMerge in Access
Docmd.MailMerge
objWord.Execute MailMerge
objWord.MailMerge.Execute
objWord.MailMerge
What is the difference between these commands
CreateObject("Word.Application") GetObject(,
"Word.Application")
CreateObject always creates a new object. GetObject
throws an error if no object of the class exists.
CreateObject always creates a new object. GetObject
takes an existing one or create a new one.
The difference is only in performance.
GetObject always creates a new object. CreateObject
throws an error if no object of the class exists.
What stores Excel data?
Field
Variable
(all of these)
Compartment
Which of the following snippets of VBA code
will allow you to return the first array index in the array xItems?
xItems.MoveFirst
UBound(xItems)
First(xItems)
LBound(xItems)
When integrating Excel, which VBA code will
allow you transfer data from recordset xRec in Access directly onto a
spreadsheet (xlws) in Excel.
xlws.range("A1").CopyFromRecordset xRec
xlws.CopyFromRecordset xRec
Docmd.TransferSpreadsheet xlws, xRec
Docmd.TransferDatabase xlws, xRec
Choose the VBA code to remove data from Row 2
in a multiple column listbox.
Me.List0.Remove 2
Me.List0.RemoveItem 1
Me.List0.Remove 1
Me.List0.Delete 2
As an alternative to the If.. Then..
ElseIf..Else condition, how would you format the Choose function with variable
x1 and the following conditions: "Red", "Blue",
"Yellow", "White"
Choose(x1,"Red","Blue","Yellow","White")
Choose x1, "Red", "Blue",
"Yellow", "White"
Choose(x1 = "Red", x1 = "Blue",
x1 = "Yellow", x1 = "White")
Choose x1("Red", "Blue",
"Yellow", "White")
With out creating a reference to the Microsoft
Scripting Runtime for the DLL to create a Dictionary object, choose the VBA
code to allow you to do so.
CreateObject "Dictionary.Scripting"
CreateObject("Dictionary.Scripting")
CreateObject("Scripting.Dictionary")
CreateObject("Application.Dictionary")
True or False? An 'If-Then' statement must
always be paired with an 'End If'.
False
True
When integrating Excel, instead of adding a
reference, which VBA code would you use to open Microsoft Excel.
Set xlapp =
CreateObject("Excel.Application")
Set xlapp = Excel.Application
Set xlapp = CreateObject("Windows.Excel")
Set xlapp =
CreateObject("Application.Excel")
Choose the VBA code used to add a new record
to the recordset xRec.
xRec.AddNew
xRec.Edit
xRec.Add
xRec.AddItem
Choose the VBA code that you would use to
obtain the user login on a computer using a Windows operating system.
CurrentDb.User
Environ("User")
CurrentProject.UserLogin
Environ("Username")
In Access, which VBA code will allow you to
suppress alerts when deleting records from a table.
DoCmd.Alerts Off
DoCmd.Alerts False
DoCmd.SetWarnings Off
DoCmd.SetWarnings False
Where you can create you custom events?
Only in classes
Only in userforms
Only in modules
Classes and userforms but not in modules
You can't create custom events
Is it possible to expand storage space for
dynamic Array variables with two or more dimensions, keeping the existing data?
Yes, by changing the size of only the last dimension.
Yes, by changing the size of only the first
dimension.
No.
Yes, without restrictions.
Which Will Not display VBA code?
VBA view
Alt-F11
Right mouse click workbook sheet then select view
code
Click Developer option in the ribbon then click
Visual Basic button
You want to dump the values stored in a
12-element array named Rates into the cell range A1:A12. How can you get
that done?
Range("A1:A12") =
Application.WorksheetFunction.Transpose(Rates)
Range("A1:A12") = Rates
Range("A1:A12") = Rates(1 to 12)
Range("A1:A12") = Rates(12)
The application property that will assign a
shortcut key to run a macro is:
OnKey
Keystoke
ShortKey
Shortcut
Which function will allow you to convert a
value to number?
CStr
CLng
CVal
CCurr
When you have added a new linked table using
VBA code and it does not appear in Navigation Pane that displays the list of
tables, forms, macros, and queries in the database. Which VBA code would
you use to update the list of database objects displayed in the Navigation
Pane.
Application.Refresh
Application.RefreshDatabaseWindow
CurrentDb.RefreshDatabase
CurrentDb.Refresh
Which statement will assign a random integer
from 1 to 5 to the variable x?
x = Int(Rnd * 5)
x = Int(Rnd * 5) + 1
x = Int(Rnd * 5 + 1)
x =Rnd * 5
Choose the VBA code to filter the rowsource in
a multiple column listbox that will allow you to filter the records
listed using the LIKE statement and the variable xCompany.
Me.List0.RowSource = "SELECT * FROM tblOrders
WHERE Company LIKE *" & xCompany
Me.List0.RowSource = "SELECT * FROM tblOrders
WHERE Company LIKE '*" & xCompany & "*'"
Me.List0.RowSource = ʺSELECT * FROM tblOrders WHERE Company
LIKE *'ʺ & xCompany & ʺ'*ʺ
Me.List0.RowSource = ʺSELECT * FROM tblOrders WHERE Company
LIKE 'ʺ & xCompany & ʺ'ʺ
Which is NOT a method of the Workspace object:
Activate
Close
What will Format(“A123”,
“&&&&&&”) output?
None of the above
“&&&A123”
“&A&1&2&3&&”
“A123”
“A123&&&”
Without using SQL, choose the VBA code to
allow you to delete the table Employees.
CurrentDb.Execute DeleteTable,
"Employees"
Docmd.Delete "Employees"
Docmd.Execute "Employees", Delete
CurrentDb.TableDefs.Delete "Employees"
The ____________ allow(s) for multiple
controls in a user form, to execute the same sub.
single command button
option buttons
class module
grouped controls
Choose the VBA code that will allow you to
check to see if the form MainMenufrm is loaded.
If IsObject("MainMenufrm").Open Then
If Forms!MainMenufrm.IsLoaded Then
If CurrentProject.AllForms("MainMenufrm").IsLoaded
Then
If IsObject("MainMenufrm").IsLoaded Then
Choose the VBA code that you would use to call
a public function named VBAFunction from a form
called FormA while passing a variant x1 in the module of FormB
form.
Call VBAFunction x1
Forms!FormA.VBAFunction(x1)
Call VBAFunction(x1)
Forms!FormA.VBAFunction x1
What is a result of this code? Sub Test() Dim
myNumber As Double myNumber = -10.635 Debug.Print Fix(myNumber) Debug.Print
Int(myNumber) End Sub
-11 -11
-10 -10
11 11
-10 -11
10 11
What is the short cut to get Immediate Window
Ctrl + M
Ctrl + W
Ctrl + I
Ctrl + G
Out put of below code: Dim a As Single Dim b
As Single a = 7 b = 2 MsgBox a / b & ", " & a \ b
3.5, 3.5
3, 3
3, 3.5
3.5, 3
To remove the records listed in a subform, which
property and value would you need to add to your VBA code.
RowSource = Null
ControlSource = ""
RowSource = ""
RecordSource = ""
Choose the VBA code used to close database and
the Microsoft Access instance.
Docmd.Close
CurrentProject.Quit
Me.Close
Docmd.Quit
Output of below code: Dim a As Integer Dim b
As Integer a = 1000 b = 33 MsgBox a * b
Run-time error '6': Overflow
32767
0
33000
Which of the following would NOT be a good use
for a macro?
Inserting a logo on all spreadsheets
Performing the same calculation on multiple
workbooks
Computing statistical calculations on data
Which tools should be used to compile the
program?
Package & Deployment Wizard
MS Visual Compiler
.Exe Generator
Data Object Viewer
Setup Creator
What reference will you add to add active x
objects ,i.e. buttons, at runtime?
Microsoft Visual Basic for Applications
Extensibility Library
Microsoft Active X Data Objects Microsoft Add-In
Designer OLE Automation
To change the font color a textbox field,
choose the VBA code that will allow you change the control's property.
Me.Text11.Font.Color = vbRed
Me.Text11.FontColor = vbRed
Me.Text11.ForeColor = vbRed
Me.Text11.BackColor = vbRed
A VBA unit is called a _____.
Event Procedure
Executor
Program
Routine
Subroutine
Choose the VBA code to allow you to obtain the
value from Row 2 and Column 3 of a mutliple column listbox.
Me.List0.Column 3, 2
Me.List0.Column(2,1)
Me.List0.Column 2, 1
Me.List0.Column(3,2)
To create one array variable to store monthly
mortgage rates over the course of a year, the following is the best declaration
statement.
Dim Rates(1 to 12) as Single
Dim Rates(1..12) as Integer
Dim Rates(1 to 12) as Decimal
Dim Rates(12) as Single
Choose the function used to send an table's
contents in Excel format by email from Access.
call SendObject(acSendTable,
"tblEmployees", acFormatXLS, "Sally Moore;")
Docmd.SendObject(acSendTable,
"tblEmployees", acFormatXLS, "Sally Moore;")
Docmd.SendEmail(acSendTable,
"tblEmployees", acFormatXLS, "Sally Moore;")
Application.SendEmail(acSendTable,
"tblEmployees", acFormatXLS, "Sally Moore;")
To concatenate two lines of VBA code into one
line, insert which character between the two joined lines?
&
,
:
;
In order to prevent users from deleting
database objects displayed in the Navigation Pane, what VBA code would be used?
Docmd.LockNavigationPane True
Me.NavigationPane.Locked = True
CurrentDb.NavigationPane.Locked = True
Application.LockNavigationPane = True
To return the value of the Access database
file's path, what VBA code will retrieve the value?
Application.FilePath
CurrentDB.Directory
CurDir
ChDir
How can we declare a subroutine or function in
VBA?
Public, Private
Protected, Public, Private
Public, Private, Friend
Private, Public, Internal
What is a Collection object?
An ordered set of data
An ordered set of objects
An ordered set of same type items
An ordered set of items
In the statement 'x = 400 * y', what is the
maximum value that y can be if x has been declared as in Integer?
81.5
800
81
82
What is PlainText ?
None of the above.
A property
A method
An object
Subscribe to:
Posts (Atom)