Basic Questions
- Hi guys,I just started with vba in excel,does anyone know the answers of thise two questions?Question 1
Marks: 1 Consider the following expression:
switch(MyTest, MyVal1, True, MyVal2)
Which of the following remarks about it is True?
Choose one answer. a. it is exactly equivalent to iif(MyTest = MyVal2, MyVal1, True)
b. it is exactly equivalent to iif(MyTest = MyVal1, MyVal2, True)
c. it is exactly equivalent to iif(MyTest, MyVal1, MyVal2)
d. it is exactly equivalent to iif(MyTest, MyVal2, MyVal1)
e. it is exactly equivalent to iif(MyTest = MyVal1, True, MyVal2)Question 2
Marks: 1 A variable MyVar is defined within a procedure called MyProc in a module called "Module 1".
Dim MyVar as Integer
Which of the following is most correct?
Choose one answer. a. MyVar can be used within loops and branches within MyProc but nowhere else
b. MyVar can be used anywhere within Module 1, but not outside the module
c. MyVar can be used within the procedure MyProc but no where else
d. MyVar can be used within the spreadsheet, but no where else
Answers
Dear,
For Question 1:
Evaluates a list of expressions and returns a Variant value or an expression associated with the first expression in the list that is True.
Syntax:
Switch(expr-1, value-1[, expr-2, value-2 � [, expr-n,value-n]])
E.g.:
Matchup = Switch(CityName = "London", "English", CityName = "Rome", "Italian", CityName = "Paris", "French")
For your reference...
Sub po()
Dim MyTest, MyVal1, MyVal2 As Integer
MyTest = 10
MyVal1 = 11
MyVal2 = 12
ans = Switch(MyTest = 13, MyVal1, MyVal1 = 11, MyVal2)
' ans would be 12, as first condition is failed.
End Sub
For Question 2:
The answer would be c.
Regards,
Sanjay
+91-9743216573- Proposed As Answer bysanjaytw Tuesday, November 10, 2009 5:29 AM
- Marked As Answer byTim LiMSFT, ModeratorThursday, November 12, 2009 2:57 AM
All Replies
Dear,
For Question 1:
Evaluates a list of expressions and returns a Variant value or an expression associated with the first expression in the list that is True.
Syntax:
Switch(expr-1, value-1[, expr-2, value-2 � [, expr-n,value-n]])
E.g.:
Matchup = Switch(CityName = "London", "English", CityName = "Rome", "Italian", CityName = "Paris", "French")
For your reference...
Sub po()
Dim MyTest, MyVal1, MyVal2 As Integer
MyTest = 10
MyVal1 = 11
MyVal2 = 12
ans = Switch(MyTest = 13, MyVal1, MyVal1 = 11, MyVal2)
' ans would be 12, as first condition is failed.
End Sub
For Question 2:
The answer would be c.
Regards,
Sanjay
+91-9743216573- Proposed As Answer bysanjaytw Tuesday, November 10, 2009 5:29 AM
- Marked As Answer byTim LiMSFT, ModeratorThursday, November 12, 2009 2:57 AM

