Exam 7: Sub and Function Procedures

arrow
  • Select Tags
search iconSearch Question
flashcardsStudy Flashcards
  • Select Tags

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:
Verified

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:
Verified

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:
Verified

False

Usually, the statement that invokes a function will assign the function's return value to a(n) ____.

(Multiple Choice)
4.8/5
(31)

Math.Round(3.234, 2) returns the number 3.24.

(True/False)
4.7/5
(44)

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)

The syntax of the Call statement is ____.

(Multiple Choice)
4.8/5
(26)

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)

The syntax ____ displays a return value.

(Multiple Choice)
4.7/5
(31)

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
close modal

Filters

  • Essay(0)
  • Multiple Choice(0)
  • Short Answer(0)
  • True False(0)
  • Matching(0)