excel programming
EET 1003
Page 1 of 5
Excel with Visual Basic for Applications : EXAM # 10 Reference: Lectures 11 & 12
TRUE/FALSE Indicate whether the statement is true or false
1. A Byte is a group of 8 bits.
2. A Boolean data type is represented by 4 bytes in VBA.
3. Currency is one of many data types in VBA.
4. In VBA, a variable name is not case sensitive.
5. Implicit Declaration means that variables are used without declaring them.
6. It is a good practice to declare all the variables you want to use.
7. The variables StudentGrade and STUDENTGRADE represent different variables.
8. Dim answer As Integer Declares the variable answer of type double
9. Range("A1").Value Refers to the contents of cell A1 in Excel sheet 1
10. Cells(1, 1).Value Refers to the contents of cell B1 in Excel sheet 1
EET 1003
Page 2 of 5
11. Const PI = 3.14159 In the above declaration, PI is declared as a constant
12. LCase() and UCase are example of string functions in VBA.
13. Perimeter = 2 / Radius In the above expression, Perimeter and Radius are of type double. If Radius=4, then the value of Perimeter is 1.5
14. The function MsgBox() is used to output user data .
15. The function InputBox() is used to collect user input data.
16. The value 3.1456 is an example of Type Integer in VBA.
17. Left() is a string function in VBA.
EET 1003
Page 3 of 5
Multiple Choice Identify the choice that best completes the statement or answers the question. Questions 18-21, refer to the following VBA program Option Explicit Dim answer As Integer, subb As Integer Dim Num1 As Integer, Num2 As Integer Private Sub AddValue() Num1 = 22 Num2 = 11 Range("B2").Value = Num1 + Num2 answer = 100 answer = answer + 1 MsgBox (Range("B2").Value) MsgBox ("value of cell b2 using range syntax is " & Range("b2").Value) Cells(5, 4).Value = "hello" MsgBox (answer) End Sub
18. Option Explicit means that a. All variables are to be declared c. The number of variables cannot
exceed 100 b. All variables are case sensitive d. Constants cannot be used
19. What is the content of cell B2 after the program finishes execution? a. 22 c. 33 b. 11 d. 2
20. In the above code, Cells(5, 4).Value refers to the value of Excel cell a. D5 c. C1 b. D4 d. C4
21. What is the value displayed in the last dialog box after the program finishes execution? a. 100 c. HELLo b. Msg d. 101
EET 1003
Page 4 of 5
Questions 22-30, refer to the following the code Dim MyString As String Sub Testing() MyString = "I went to School" MsgBox ("Length is " & Len(MyString)) ' string length MsgBox (UCase(MyString)) ' to upper case MsgBox (LCase(MyString)) ' to lower case MsgBox (MyString) ' string as is End Sub
22. If you run the above code, how many dialog boxes will be displayed? a. 4 c. 3 b. 5 d. 6
23. The first dialog box will display a. Length is 16 c. I WENT TO SCHOOL b. I went to School d. i went to school
24. The second dialog box will display a. Length is 16 c. I WENT TO SCHOOL b. I went to School d. i went to school
25. The third dialog box will display a. Length is 16 c. I WENT TO SCHOOL b. I went to School d. i went to school
26. The fourth dialog box will display a. Length is 16 c. I WENT TO SCHOOL b. I went to School d. i went to school
27. The function UCase(string) converts a string to a. Lower case c. color red b. Upper case d. color green
EET 1003
Page 5 of 5
28. The function LCase(string) converts a string to a. Lower case c. Integer b. Upper case d. Double
29. The variable Mystring is declared of type a. Double c. String b. Integer d. Currency
30. In the above code, the parts of the code in green color a. Run at the end c. Are colored for fun b. Run in the beginning d. Do not run because they are
comments