Deck 7: Sub and Function Procedures

Full screen (f)
exit full mode
Question
An event procedure is a Function procedure that is associated with a specific object and event.
Use Space or
up arrow
down arrow
to flip the card.
Question
The ____ keyword in a function header identifies the data type of the data being returned.

A) Is
B) DataType
C) As
D) Return
Question
A Function procedure does not return a value after performing its assigned task.
Question
You can determine whether a variable is being passed by value or by reference by looking at the Call statement.
Question
The number of arguments listed in the Call statement's argumentList should agree with the number of parameters listed in the parameterList in the procedure header.
Question
The names of the arguments in a Call statement need to be identical to the names of the corresponding parameters.
Question
The computer automatically processes an event procedure when the event occurs.
Question
When you pass a variable ____,the computer passes only the contents of the variable to the receiving procedure.

A) by reference
B) by parameter
C) by dataType
D) by value
Question
It is a common practice to begin a procedure's name with a(n)____.

A) noun
B) verb
C) adjective
D) adverb
Question
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.

A) by reference
B) by parameter
C) by dataType
D) by value
Question
Like a Sub procedure header,a Function procedure header includes the As dataType section.
Question
The syntax of the Call statement is ____.

A) Call procedureName([argumentList])
B) Call procedureName{[parameterList]}
C) Call procedureName([argumentList],dataType)
D) Call procedureName([argumentList])As dataType
Question
Visual Basic allows you to specify that an argument in the Call statement is optional.
Question
A(n)____ is processed only when it is called (invoked)from code.

A) dependent Sub procedure
B) independent Sub procedure
C) event procedure
D) independent event procedure
Question
An independent Sub procedure is a procedure that is independent of any object and event.
Question
Math.Round(3.234,2)returns the number 3.24.
Question
Usually,the statement that invokes a function will assign the function's return value to a(n)____.

A) address
B) argument
C) variable
D) parameter
Question
When using ____,you capitalize the first letter in the procedure name and the first letter of each subsequent word in the name.

A) sentence case
B) camel case
C) object case
D) Pascal case
Question
In most cases,the last statement within a function is the ____ expression.

A) End Function
B) Return
C) As
D) Private
Question
An independent Sub procedure can contain one or more ____ in its procedure header that have procedure scope and store an item of data.

A) events
B) variables
C) constraints
D) parameters
Question
Like the first item in a list box,the first item in a combo box has an index of ____.

A) 0
B) 1
C) 2
D) 3
Question
The expression Math.Round(287.876,2)yields a value of ____.

A) 287.87
B) 287.88
C) 288.00
D) 290.00
Question
To sort the items in the list portion of a combo box,you use the combo box's ____ property.

A) Sorted
B) Ascending
C) Descending
D) TabIndex
Question
In a ____ combo box,the text portion is not editable.

A) Text
B) Simple
C) DropDown
D) DropDownList
Question
The syntax ____ displays a return value. The syntax ____ displays a return value.  <div style=padding-top: 35px>
Question
A combo box's ____ property contains the value that appears in the text portion of the control.

A) Add
B) Sorted
C) Text
D) list
Question
The syntax ____ assigns a return value to a variable. The syntax ____ assigns a return value to a variable.  <div style=padding-top: 35px>
Question
Which of the following statements will determine the number of items in the list portion of the Department combo box? Which of the following statements will determine the number of items in the list portion of the Department combo box?  <div style=padding-top: 35px>
Question
If the digits argument is omitted,the Math.Round function returns a(n)____.

A) zero
B) exception
C) error
D) integer
Question
____ styles of combo boxes are available in Visual Basic.

A) Two
B) Three
C) Four
D) Five
Question
A ____ is similar to a list box in that it allows the user to select from a list of choices.

A) text box
B) message box
C) combo box
D) dialog box
Question
Which of the following is a valid Return statement?

A) dblNumber Return
B) Return dblNumber ByRef
C) Return ByRef dblNumber
D) Return dblNumber
Question
Which of the following is a valid header for a procedure that is passed the number 9.75? Which of the following is a valid header for a procedure that is passed the number 9.75?  <div style=padding-top: 35px>
Question
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? 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?  <div style=padding-top: 35px>
Question
As you do with list boxes,you use the Items collection's ____ method to add an item to a combo box.

A) Insert
B) Add
C) New
D) Append
Question
An application calculates an ending inventory amount based on a beginning inventory amount,sales,and returns.You need to create a function to calculate the ending inventory using three passed Integer variables: intBegin,intSales,and intReturns.Which of the following procedure headers should be used? An application calculates an ending inventory amount based on a beginning inventory amount,sales,and returns.You need to create a function to calculate the ending inventory using three passed Integer variables: intBegin,intSales,and intReturns.Which of the following procedure headers should be used?  <div style=padding-top: 35px>
Question
For the access key to work correctly in a combo box,you must set the label's TabIndex property to a value that is ____ the combo box's TabIndex value.

A) identical to
B) one less than
C) one more than
D) greater than or equal to
Question
The default combo box style in Visual Basic is ____.

A) Text
B) Simple
C) DropDown
D) DropDownList
Question
Which of the following statements would invoke the GetEndInventory function and assign the function's return value to the intEnd variable? Which of the following statements would invoke the GetEndInventory function and assign the function's return value to the intEnd variable?  <div style=padding-top: 35px>
Question
A form's ____ procedure is responsible for verifying that the user wants to close the application,and then taking the appropriate action based on the user's response.

A) Click event
B) FormClosing event
C) Add event
D) Button event
Question
Write the code for a Sub procedure named InitializeVariables.The Sub procedure will assign the number 0 to the intTotalCars,intTotalTrucks,intTotalSUVs.Then write the code to call the procedure.
Question
What is the Math.Round function? Provide the function's syntax and define the arguments.
Question
Explain the difference between passing data by value and passing data by reference.
Question
Write the code for a Sub procedure named DisplayAuto,which displays a message containing the two values passed to it: an automobile make and model.Use strMake and strModel as the parameters.Display the "You own a make model." message in a message box.Then write the statement to invoke the procedure,passing it the contents of the strBrand and strType variables,respectively.
Question
How do the parameterList of a procedure header and the argumentList of a Call statement relate to each other?
Question
When will the TextChanged event occur for a combo box? Which style allows the user to edit the text of the combo box?
Question
An application allows a user to scan a bar code of an item to determine the item price.A message that contains the item name and the item price should display.You need to create a Sub procedure to display the message.Which of the following procedure headers should be used? An application allows a user to scan a bar code of an item to determine the item price.A message that contains the item name and the item price should display.You need to create a Sub procedure to display the message.Which of the following procedure headers should be used?  <div style=padding-top: 35px>
Question
Write the code for a Sub procedure named CalculateAverage that receives four decimal variables (the first three by value and the last one by reference).The procedure should use the first three variables to calculate the average and then store the result in the fourth variable.
Question
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.
Question
Write the code for a function named CalculateBonus.The function receives two decimal variables representing the salary and bonus rate.The function should calculate the bonus amount by multiplying the salary by the bonus rate,and then return the result.Then write the appropriate statement to invoke the function,passing it the decSalary and decRate variables.Assign the function's return value to the decBonus variable.
Question
Which of the following statements would invoke the DisplayMessage Sub procedure? Which of the following statements would invoke the DisplayMessage Sub procedure?  <div style=padding-top: 35px>
Question
Write the code for a Sub procedure named CalculateBonus.The procedure receives three decimal variables representing the salary,bonus rate,and bonus amount.The procedure should calculate the bonus amount by multiplying the salary by the bonus rate.Create your own variable names.
Question
Write the code to add Freshman,Sophomore,Junior,and Senior to the Class combo box.Use the SelectedItem property to make Freshman the default item.
Question
An application uses a message box to ask users whether they want to exit the application,and the return value is stored in the dlgButton variable.Write the statement needed to stop the computer from closing the form if the user selects the No button in the message box.
Question
An application needs to calculate sales tax for purchases.You decide to simplify the code by putting the sales tax calculation in a function.The returned value from the function is then added to the Subtotal,and the result is stored in the decTotal variable.Which of the following statements will call the GetSalesTax function and return a value to be used in the Total calculation? An application needs to calculate sales tax for purchases.You decide to simplify the code by putting the sales tax calculation in a function.The returned value from the function is then added to the Subtotal,and the result is stored in the decTotal variable.Which of the following statements will call the GetSalesTax function and return a value to be used in the Total calculation?  <div style=padding-top: 35px>
Question
What is the difference between a Sub procedure and a Function procedure?
Unlock Deck
Sign up to unlock the cards in this deck!
Unlock Deck
Unlock Deck
1/56
auto play flashcards
Play
simple tutorial
Full screen (f)
exit full mode
Deck 7: Sub and Function Procedures
1
An event procedure is a Function procedure that is associated with a specific object and event.
False
2
The ____ keyword in a function header identifies the data type of the data being returned.

A) Is
B) DataType
C) As
D) Return
C
3
A Function procedure does not return a value after performing its assigned task.
False
4
You can determine whether a variable is being passed by value or by reference by looking at the Call statement.
Unlock Deck
Unlock for access to all 56 flashcards in this deck.
Unlock Deck
k this deck
5
The number of arguments listed in the Call statement's argumentList should agree with the number of parameters listed in the parameterList in the procedure header.
Unlock Deck
Unlock for access to all 56 flashcards in this deck.
Unlock Deck
k this deck
6
The names of the arguments in a Call statement need to be identical to the names of the corresponding parameters.
Unlock Deck
Unlock for access to all 56 flashcards in this deck.
Unlock Deck
k this deck
7
The computer automatically processes an event procedure when the event occurs.
Unlock Deck
Unlock for access to all 56 flashcards in this deck.
Unlock Deck
k this deck
8
When you pass a variable ____,the computer passes only the contents of the variable to the receiving procedure.

A) by reference
B) by parameter
C) by dataType
D) by value
Unlock Deck
Unlock for access to all 56 flashcards in this deck.
Unlock Deck
k this deck
9
It is a common practice to begin a procedure's name with a(n)____.

A) noun
B) verb
C) adjective
D) adverb
Unlock Deck
Unlock for access to all 56 flashcards in this deck.
Unlock Deck
k this deck
10
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.

A) by reference
B) by parameter
C) by dataType
D) by value
Unlock Deck
Unlock for access to all 56 flashcards in this deck.
Unlock Deck
k this deck
11
Like a Sub procedure header,a Function procedure header includes the As dataType section.
Unlock Deck
Unlock for access to all 56 flashcards in this deck.
Unlock Deck
k this deck
12
The syntax of the Call statement is ____.

A) Call procedureName([argumentList])
B) Call procedureName{[parameterList]}
C) Call procedureName([argumentList],dataType)
D) Call procedureName([argumentList])As dataType
Unlock Deck
Unlock for access to all 56 flashcards in this deck.
Unlock Deck
k this deck
13
Visual Basic allows you to specify that an argument in the Call statement is optional.
Unlock Deck
Unlock for access to all 56 flashcards in this deck.
Unlock Deck
k this deck
14
A(n)____ is processed only when it is called (invoked)from code.

A) dependent Sub procedure
B) independent Sub procedure
C) event procedure
D) independent event procedure
Unlock Deck
Unlock for access to all 56 flashcards in this deck.
Unlock Deck
k this deck
15
An independent Sub procedure is a procedure that is independent of any object and event.
Unlock Deck
Unlock for access to all 56 flashcards in this deck.
Unlock Deck
k this deck
16
Math.Round(3.234,2)returns the number 3.24.
Unlock Deck
Unlock for access to all 56 flashcards in this deck.
Unlock Deck
k this deck
17
Usually,the statement that invokes a function will assign the function's return value to a(n)____.

A) address
B) argument
C) variable
D) parameter
Unlock Deck
Unlock for access to all 56 flashcards in this deck.
Unlock Deck
k this deck
18
When using ____,you capitalize the first letter in the procedure name and the first letter of each subsequent word in the name.

A) sentence case
B) camel case
C) object case
D) Pascal case
Unlock Deck
Unlock for access to all 56 flashcards in this deck.
Unlock Deck
k this deck
19
In most cases,the last statement within a function is the ____ expression.

A) End Function
B) Return
C) As
D) Private
Unlock Deck
Unlock for access to all 56 flashcards in this deck.
Unlock Deck
k this deck
20
An independent Sub procedure can contain one or more ____ in its procedure header that have procedure scope and store an item of data.

A) events
B) variables
C) constraints
D) parameters
Unlock Deck
Unlock for access to all 56 flashcards in this deck.
Unlock Deck
k this deck
21
Like the first item in a list box,the first item in a combo box has an index of ____.

A) 0
B) 1
C) 2
D) 3
Unlock Deck
Unlock for access to all 56 flashcards in this deck.
Unlock Deck
k this deck
22
The expression Math.Round(287.876,2)yields a value of ____.

A) 287.87
B) 287.88
C) 288.00
D) 290.00
Unlock Deck
Unlock for access to all 56 flashcards in this deck.
Unlock Deck
k this deck
23
To sort the items in the list portion of a combo box,you use the combo box's ____ property.

A) Sorted
B) Ascending
C) Descending
D) TabIndex
Unlock Deck
Unlock for access to all 56 flashcards in this deck.
Unlock Deck
k this deck
24
In a ____ combo box,the text portion is not editable.

A) Text
B) Simple
C) DropDown
D) DropDownList
Unlock Deck
Unlock for access to all 56 flashcards in this deck.
Unlock Deck
k this deck
25
The syntax ____ displays a return value. The syntax ____ displays a return value.
Unlock Deck
Unlock for access to all 56 flashcards in this deck.
Unlock Deck
k this deck
26
A combo box's ____ property contains the value that appears in the text portion of the control.

A) Add
B) Sorted
C) Text
D) list
Unlock Deck
Unlock for access to all 56 flashcards in this deck.
Unlock Deck
k this deck
27
The syntax ____ assigns a return value to a variable. The syntax ____ assigns a return value to a variable.
Unlock Deck
Unlock for access to all 56 flashcards in this deck.
Unlock Deck
k this deck
28
Which of the following statements will determine the number of items in the list portion of the Department combo box? Which of the following statements will determine the number of items in the list portion of the Department combo box?
Unlock Deck
Unlock for access to all 56 flashcards in this deck.
Unlock Deck
k this deck
29
If the digits argument is omitted,the Math.Round function returns a(n)____.

A) zero
B) exception
C) error
D) integer
Unlock Deck
Unlock for access to all 56 flashcards in this deck.
Unlock Deck
k this deck
30
____ styles of combo boxes are available in Visual Basic.

A) Two
B) Three
C) Four
D) Five
Unlock Deck
Unlock for access to all 56 flashcards in this deck.
Unlock Deck
k this deck
31
A ____ is similar to a list box in that it allows the user to select from a list of choices.

A) text box
B) message box
C) combo box
D) dialog box
Unlock Deck
Unlock for access to all 56 flashcards in this deck.
Unlock Deck
k this deck
32
Which of the following is a valid Return statement?

A) dblNumber Return
B) Return dblNumber ByRef
C) Return ByRef dblNumber
D) Return dblNumber
Unlock Deck
Unlock for access to all 56 flashcards in this deck.
Unlock Deck
k this deck
33
Which of the following is a valid header for a procedure that is passed the number 9.75? Which of the following is a valid header for a procedure that is passed the number 9.75?
Unlock Deck
Unlock for access to all 56 flashcards in this deck.
Unlock Deck
k this deck
34
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? 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?
Unlock Deck
Unlock for access to all 56 flashcards in this deck.
Unlock Deck
k this deck
35
As you do with list boxes,you use the Items collection's ____ method to add an item to a combo box.

A) Insert
B) Add
C) New
D) Append
Unlock Deck
Unlock for access to all 56 flashcards in this deck.
Unlock Deck
k this deck
36
An application calculates an ending inventory amount based on a beginning inventory amount,sales,and returns.You need to create a function to calculate the ending inventory using three passed Integer variables: intBegin,intSales,and intReturns.Which of the following procedure headers should be used? An application calculates an ending inventory amount based on a beginning inventory amount,sales,and returns.You need to create a function to calculate the ending inventory using three passed Integer variables: intBegin,intSales,and intReturns.Which of the following procedure headers should be used?
Unlock Deck
Unlock for access to all 56 flashcards in this deck.
Unlock Deck
k this deck
37
For the access key to work correctly in a combo box,you must set the label's TabIndex property to a value that is ____ the combo box's TabIndex value.

A) identical to
B) one less than
C) one more than
D) greater than or equal to
Unlock Deck
Unlock for access to all 56 flashcards in this deck.
Unlock Deck
k this deck
38
The default combo box style in Visual Basic is ____.

A) Text
B) Simple
C) DropDown
D) DropDownList
Unlock Deck
Unlock for access to all 56 flashcards in this deck.
Unlock Deck
k this deck
39
Which of the following statements would invoke the GetEndInventory function and assign the function's return value to the intEnd variable? Which of the following statements would invoke the GetEndInventory function and assign the function's return value to the intEnd variable?
Unlock Deck
Unlock for access to all 56 flashcards in this deck.
Unlock Deck
k this deck
40
A form's ____ procedure is responsible for verifying that the user wants to close the application,and then taking the appropriate action based on the user's response.

A) Click event
B) FormClosing event
C) Add event
D) Button event
Unlock Deck
Unlock for access to all 56 flashcards in this deck.
Unlock Deck
k this deck
41
Write the code for a Sub procedure named InitializeVariables.The Sub procedure will assign the number 0 to the intTotalCars,intTotalTrucks,intTotalSUVs.Then write the code to call the procedure.
Unlock Deck
Unlock for access to all 56 flashcards in this deck.
Unlock Deck
k this deck
42
What is the Math.Round function? Provide the function's syntax and define the arguments.
Unlock Deck
Unlock for access to all 56 flashcards in this deck.
Unlock Deck
k this deck
43
Explain the difference between passing data by value and passing data by reference.
Unlock Deck
Unlock for access to all 56 flashcards in this deck.
Unlock Deck
k this deck
44
Write the code for a Sub procedure named DisplayAuto,which displays a message containing the two values passed to it: an automobile make and model.Use strMake and strModel as the parameters.Display the "You own a make model." message in a message box.Then write the statement to invoke the procedure,passing it the contents of the strBrand and strType variables,respectively.
Unlock Deck
Unlock for access to all 56 flashcards in this deck.
Unlock Deck
k this deck
45
How do the parameterList of a procedure header and the argumentList of a Call statement relate to each other?
Unlock Deck
Unlock for access to all 56 flashcards in this deck.
Unlock Deck
k this deck
46
When will the TextChanged event occur for a combo box? Which style allows the user to edit the text of the combo box?
Unlock Deck
Unlock for access to all 56 flashcards in this deck.
Unlock Deck
k this deck
47
An application allows a user to scan a bar code of an item to determine the item price.A message that contains the item name and the item price should display.You need to create a Sub procedure to display the message.Which of the following procedure headers should be used? An application allows a user to scan a bar code of an item to determine the item price.A message that contains the item name and the item price should display.You need to create a Sub procedure to display the message.Which of the following procedure headers should be used?
Unlock Deck
Unlock for access to all 56 flashcards in this deck.
Unlock Deck
k this deck
48
Write the code for a Sub procedure named CalculateAverage that receives four decimal variables (the first three by value and the last one by reference).The procedure should use the first three variables to calculate the average and then store the result in the fourth variable.
Unlock Deck
Unlock for access to all 56 flashcards in this deck.
Unlock Deck
k this deck
49
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.
Unlock Deck
Unlock for access to all 56 flashcards in this deck.
Unlock Deck
k this deck
50
Write the code for a function named CalculateBonus.The function receives two decimal variables representing the salary and bonus rate.The function should calculate the bonus amount by multiplying the salary by the bonus rate,and then return the result.Then write the appropriate statement to invoke the function,passing it the decSalary and decRate variables.Assign the function's return value to the decBonus variable.
Unlock Deck
Unlock for access to all 56 flashcards in this deck.
Unlock Deck
k this deck
51
Which of the following statements would invoke the DisplayMessage Sub procedure? Which of the following statements would invoke the DisplayMessage Sub procedure?
Unlock Deck
Unlock for access to all 56 flashcards in this deck.
Unlock Deck
k this deck
52
Write the code for a Sub procedure named CalculateBonus.The procedure receives three decimal variables representing the salary,bonus rate,and bonus amount.The procedure should calculate the bonus amount by multiplying the salary by the bonus rate.Create your own variable names.
Unlock Deck
Unlock for access to all 56 flashcards in this deck.
Unlock Deck
k this deck
53
Write the code to add Freshman,Sophomore,Junior,and Senior to the Class combo box.Use the SelectedItem property to make Freshman the default item.
Unlock Deck
Unlock for access to all 56 flashcards in this deck.
Unlock Deck
k this deck
54
An application uses a message box to ask users whether they want to exit the application,and the return value is stored in the dlgButton variable.Write the statement needed to stop the computer from closing the form if the user selects the No button in the message box.
Unlock Deck
Unlock for access to all 56 flashcards in this deck.
Unlock Deck
k this deck
55
An application needs to calculate sales tax for purchases.You decide to simplify the code by putting the sales tax calculation in a function.The returned value from the function is then added to the Subtotal,and the result is stored in the decTotal variable.Which of the following statements will call the GetSalesTax function and return a value to be used in the Total calculation? An application needs to calculate sales tax for purchases.You decide to simplify the code by putting the sales tax calculation in a function.The returned value from the function is then added to the Subtotal,and the result is stored in the decTotal variable.Which of the following statements will call the GetSalesTax function and return a value to be used in the Total calculation?
Unlock Deck
Unlock for access to all 56 flashcards in this deck.
Unlock Deck
k this deck
56
What is the difference between a Sub procedure and a Function procedure?
Unlock Deck
Unlock for access to all 56 flashcards in this deck.
Unlock Deck
k this deck
locked card icon
Unlock Deck
Unlock for access to all 56 flashcards in this deck.