Exam 7: Sub and Function Procedures
Exam 1: An Introduction to Visual Basic 201560 Questions
Exam 2: Designing Applications60 Questions
Exam 3: Using Variables and Constants60 Questions
Exam 4: The Selection Structure59 Questions
Exam 5: More on the Selection Structure60 Questions
Exam 6: The Repetition Structure60 Questions
Exam 7: Sub and Function Procedures60 Questions
Exam 8: String Manipulation60 Questions
Exam 9: Arrays60 Questions
Exam 10: Structures and Sequential Access Files60 Questions
Exam 11: Classes and Objects60 Questions
Exam 12: Web Applications60 Questions
Exam 13: Working With Access Databases and Linq60 Questions
Exam 14: Access Databases and Sql60 Questions
Select questions type
Write the code for a function named GetMajor . The function should prompt the user to enter a major field of study and then return the user's response. Then write a statement to invoke the GetMajor function, returning the result to the strCurrentMajor variable.
Free
(Essay)
4.8/5
(31)
Correct Answer:
Private Function GetMajor() As String
Dim strMajor As String
strMajor = InputBox("Please enter your major:", "Major")
Return strMajor
End Function
strCurrentMajor = GetMajor()
Which of the following is a valid header for a procedure that is passed the number 9.75?
Free
(Multiple Choice)
4.8/5
(33)
Correct Answer:
C
You can determine whether a variable is being passed by value or by reference by looking at the Call statement.
Free
(True/False)
4.9/5
(38)
Correct Answer:
False
Usually, the statement that invokes a function will assign the function's return value to a(n) ____.
(Multiple Choice)
4.8/5
(31)
What is a combo box? List the three styles of combo boxes available in Visual Basic.
(Essay)
4.8/5
(36)
Problems - Correcting Logic and Code Errors
The following sample of code contains errors. Rewrite the incorrect statements to correct all errors.
' calculate and return the miles per gallon
Private Function GetMPG(ByVal dblMiles,
ByVal dblGallons) As Double
Return dblMPG = dblMiles / dblGallons
End Sub
' call the function to calculate miles per gallon
' pass variables for the calculation
intMPG = GetMPG()
(Essay)
4.8/5
(43)
An independent Sub procedure is a procedure that is independent of any object and event.
(True/False)
4.8/5
(30)
Explain the difference between passing data by value and passing data by reference .
(Essay)
4.8/5
(32)
Like a Sub procedure header, a Function procedure header includes the As dataType section.
(True/False)
4.7/5
(37)
You pass a variable ____ when the receiving procedure needs to know the variable's contents, but the receiving procedure does not need to change the contents.
(Multiple Choice)
4.7/5
(35)
Visual Basic allows you to specify that an argument in the Call statement is optional.
(True/False)
4.8/5
(27)
The computer automatically processes an event procedure when the event occurs.
(True/False)
4.9/5
(33)
Which of the following is a valid header for a procedure that receives the address of a string variable and the address of an integer?
(Multiple Choice)
4.9/5
(34)
It is a common practice to begin a procedure's name with a(n) ____.
(Multiple Choice)
4.8/5
(42)
To sort the items in the list portion of a combo box, you use the combo box's ____ property.
(Multiple Choice)
4.7/5
(38)
If the digits argument is omitted, the Math.Round function returns a(n) ____.
(Multiple Choice)
5.0/5
(29)
The expression Math.Round(287.876, 2) yields a value of ____.
(Multiple Choice)
4.9/5
(30)
Showing 1 - 20 of 60
Filters
- Essay(0)
- Multiple Choice(0)
- Short Answer(0)
- True False(0)
- Matching(0)