0% found this document useful (0 votes)
5 views3 pages

Basic Practice Final

Copyright
© © All Rights Reserved
We take content rights seriously. If you suspect this is your content, claim it here.
Available Formats
Download as PDF, TXT or read online on Scribd
0% found this document useful (0 votes)
5 views3 pages

Basic Practice Final

Copyright
© © All Rights Reserved
We take content rights seriously. If you suspect this is your content, claim it here.
Available Formats
Download as PDF, TXT or read online on Scribd
You are on page 1/ 3

Visual Basic Practice Final Exam Name - __________________________________

Period - ___________
True/False
1. Dim scores As Integer(10) declares an array of integers.
2. At least one parameter must be passed to a function.
3. The Enabled property can be used with menu command objects (i.e. menu items.)
4. The Close method is used to make a message box disappear.
5. An array is a type of method.
6. The scope of a variable declared outside of all the methods on a form is wider than that of a local variable.
7. A form has a method named KeyClick that executes when the user presses a key on the keyboard.
8. The statement num =+ 3 causes three to be added to the original value of the variable num.

For the following set of questions indicate True or False depending on whether syntax errors are present. Do not
consider logic errors. Remember that a syntax error is an error that prevents VB from executing a statement or
line of code. You can assume that variables with the int prefix are Integer variables that were properly
declared and that object names with prefixes are valid objects.

9. There are no syntax errors in the statement: Dim (5)intMyList As Integer


10. There are no syntax errors in the statement: Const MAX As Integer = 500
11. There are no syntax errors in the statement: InputBox("Enter a number: ") = intUserNum
12. There are no syntax errors in the statement: For intCounter = 1 To 4
13. There are no syntax errors in the statement: picRectangle.Top = 500

Determine the Output – Write your answers on the answer sheet that has been provided.

Trace the following code segments and answer the following questions. If a final answer is a string, make sure
that you surround the answer with double quotes ("John bDoe"). Represent blank spaces as the letter b with a
slash through it ( b ). If you believe an error exists, explain it as carefully and thoroughly as possible. Assume
that all variables and objects referred to in each code segment have been declared or created with any default
values normally supplied by Visual Basic.

For J = 0 To 5 sum J
sum = sum + J
Next

14. What is the final value of sum ?


15. What is the final value of J ?

Dim total As Integer = 0 J total


Dim numbers() As Integer = {12, 10, 8, 32, 64, 9}

For J = 0 To 4
If (numbers(J) > 10) Then
total += numbers(J)
Else
numbers(J) = 0
End If
Next
16. What is the final value of the variable total?
17. What is the final value of the variable numbers(2)?
18. What is the final value of the variable numbers(3)?
19. What is the final value of the variable numbers(5)?

Write Code - Write Visual Basic code that fulfills the following tasks. You must use any variable and object
names that are specified but you may declare additional variables if necessary.

20. Write a declaration statement for an array of Integer's named scores with length of 10.

21. Write a statement that assigns a random integer between or including 1 and 10 in the variable num.

22. Write a statement that assigns a random integer between or including 11 and 20 in the variable num.

23. Write an If statement that detections a collision between a PictureBox named picEnemy and a
horizontal line that goes from (10, 20) to (100, 20).

24. Write a For loop that finds the sum of the integers 5 through 10 and stores the final answer in the variable
sum. Use the loop variable J in the For loop.

25. Write a code segment that uses a While loop to allow the user to input integers into an InputBox until
zero is inputted. When the zero is inputted, the loop must end and the code segment must display the total of
all the inputted integers in MessageBox.
26. Write a function named DiceRoll that returns a random integer between or including 1 and 6.

Private Function DiceRoll() As Integer

End Function

27. Write a method named Reset that sets the top, left corner of a PictureBox named picPlayer to
the (x, y) coordinates of (80, 100).

Private Sub Reset()

End Sub

28. Write a code segment that uses a loop to search an array named list to determine if the value 5 is stored in
any position within list. The array has fifty elements with the subscript positions 0 to 49. If the value 5 is
found, display a message box with the phrase “5 was found”. You must declare all variables properly.

29. Write out the Hello World program that we studied in the first week of school.

30. Write out the truth table exactly as we learned this year. Use 1's and 0's rather than the words true and false.

You might also like