linkedin-skill-assessments-quizzes

Visual Basic for Applications (VBA)

Q1. Which two sets of values are printed by this function and sub?

Function GetVitals(ID As Long, Age As Long, ptional Weight As Long) As String
    GetVitals="ID=" & ID &"Age=" & Age & "Weight=" & Weight
End Function
Sub ShowVitals()
    Dim ID As Long, Age As Long,Weight as Long
    Debug.Print GetVitals(ID:=5,Age:=20)
    Debug.Print GetVitals(ID:=6,Age:=25,Weight:=130
End Sub

Q2. This code shows the first statement of CalledSub. Which calling statement will work properly?

Sub CalledSub(Surname, Age)

Q3. What is the principal difference between a class and an object?

Q4. What value does the MsgBox statement display?

Sub MySub(VarA As Long, ParamArray VarB() As Variant)
MsgBox VarB(0)
End Sub
Sub ShowValue()
Call MySub(10, "First arg", 2, 3.1416)
End Sub

Q5. What object is needed to put a userform module in a VBA project?

Q6. What is the output?

Sub UseSum()
Dim TestArray() As Integer, Total As Integer
ReDim TestArray(1)
TestArray(1) = 6
ReDim TestArray(2)
TestArray(2) = 3
Total = WorksheetFunction.Sum(TestArray)
End Sub

Q7. The Driver subroutine is declared by Sub Driver (Y). Which statement results in a compile error?

Q8. You have several variables to display on a user form, and there are too many variables to display at once. Which control best enables the user to see all the variables?

Q9. Below is a function named SquareIt. Which version of the subroutine named Area results in a compile error?

Function SquareIt(ByRef Basis As Integer) As Long
SquareIt = Basis ^ 2
End Function
Dim Result As Long, Side As Integer
Side = 5
Result = Squarelt(Side)
End Sub
Dim Result As Long, Side
Side = 5
Result = SquareIt(Cint(Side))
End Sub

Q10. EmailAddress() is an array. It is declared by Dim EmailAddress(10) As String, and option Base 1 is in effect. How many rows and columns are in EmailAddress()?

Q11. Which cell is selected if you run this code?

Range("E3:312").Range("B3").Select

Q12. Which variable name is valid in VBA?

Reference link

Use the following rules when you name procedures, constants, variables, and arguments in a Visual Basic module:
You must use a letter as the first character.
You can't use a space, period (.), exclamation mark (!), or the characters @, &, $, # in the name.
Name can't exceed 255 characters in length.