Deck 7: Sub and Function Procedures

Full screen (f)
exit full mode
Question
It is a common practice to begin a procedure's name with a(n)____.

A)noun
B)verb
C)adjective
D)adverb
Use Space or
up arrow
down arrow
to flip the card.
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
Visual Basic allows you to specify that an argument in the Call statement is optional.
Question
You can determine whether a variable is being passed by value or by reference by looking at the Call statement.
Question
Which of the following is a valid header for a procedure that is passed the number 9.75?

A)Private Function CalcSubtotal(ByVal intPrice As Integer) As Decimal
B)Private Function CalcSubtotal(ByRef intPrice As Integer) As Decimal
C)Private Function CalcSubtotal(ByVal decPrice As Decimal) As Decimal
D)Private Function CalcSubtotal(ByVal intPrice As Integer)
Question
Math.Round(3.234,2)returns the number 3.24.
Question
An event procedure is a Function procedure that is associated with a specific object and event.
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
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
An independent Sub procedure is a procedure that is independent of any object and event.
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
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
Like a Sub procedure header,a Function procedure header includes the As dataType section.
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
A Function procedure does not return a value after performing its assigned task.
Question
In most cases,the last statement within a function is the ____ expression.

A)End Function
B)Return
C)As
D)Private
Question
The names of the arguments in a Call statement need to be identical to the names of the corresponding parameters.
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
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?

A)Private Sub GetInfo(ByRef strName As String, ByRef intAge As Integer)
B)Private Sub GetInfo(ByRef strName, ByRef intAge)
C)Private Sub GetInfo(ByVal strName As String, ByVal intAge As Integer)
D)Private Sub GetInfo(ByVal strName, ByVal intAge)
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
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
The default combo box style in Visual Basic is ____.

A)Text
B)Simple
C)DropDown
D)DropDownList
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
____ styles of combo boxes are available in Visual Basic.

A)Two
B)Three
C)Four
D)Five
Question
Which of the following statements will determine the number of items in the list portion of the Department combo box?

A)cboDepartment.Count.Items
B)cboDepartment.Items.Count
C)lstDepartment.Items.Count
D)lstDepartment.Count.Items
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
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
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?

A)Private Function GetEndInventory(ByVal intBegin, ByVal intSales, ByVal intReturns) As Integer
B)Private Function GetEndInventory(ByVal intBegin As Integer, ByVal intSales As Integer, ByVal intReturns As Integer)
C)Private Function GetEndInventory(ByVal intBegin As Integer, ByVal intSales As Integer, ByVal intReturns As Integer, ByRef intEnd As Integer) As Integer
D)Private Function GetEndInventory(ByVal intBegin As Integer, ByVal intSales As Integer, ByVal intReturns As Integer) As Integer
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
The syntax ____ displays a return value.

A)dblNewPrice = GetNewPrice(dblCurrentPrice)
B)lblNewPrice.Text = GetNewPrice(dblCurrentPrice).ToString("C2")
C)Dim dblNewPrice
D)dblTotalDue = intQuantity * GetNewPrice(dblCurrentPrice)
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
Which of the following statements would invoke the GetEndInventory function and assign the function's return value to the intEnd variable?

A)Call GetEndInventory(intBegInv, intItemsSold, intReturned)
B)intEnd = Call GetEndInventory(intBegInv, intItemsSold, intReturned)
C)intEnd = GetEndInventory(intBegInv, intItemsSold, intReturned)
D)intEnd = GetEndInventory()
Question
In a ____ combo box,the text portion is not editable.

A)Text
B)Simple
C)DropDown
D)DropDownList
Question
If the digits argument is omitted,the Math.Round function returns a(n)____.

A)zero
B)exception
C)error
D)integer
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 ____ keyword in a function header identifies the data type of the data being returned.

A)Is
B)DataType
C)As
D)Return
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
The syntax ____ assigns a return value to a variable.

A)dblNewPrice = GetNewPrice(dblCurrentPrice)
B)lblNewPrice.Text = GetNewPrice(dblCurrentPrice).ToString
C)Dim dblNewPrice
D)dblNewPrice = dblCurrentPrice
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
When will the TextChanged event occur for a combo box? Which style allows the user to edit the text of the combo box?
Question
' 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()
Question
Private Sub frmMain_FormClosing(ByVal sender As Object,ByVal e As System.Windows.Forms.FormClosingEventArgs)Handles Me.FormClosing
' verify that the user wants to exit the application
Dim dlgButton As DialogResult
dlgButton = MessageBox.Show("Do you want to exit?",
"Sample Program")
' if the No button was selected,don't close the form
If dlgButton = DialogResult.Yes Then
e.Cancel = TrueEnd IfEnd SubPrivate Sub frmMain_Load(ByVal sender As Object, ByVal e As System.EventArgs) Handles Me.Load' fill combo box with values, then select default valueFor intNumber As Integer From 0 Thru 10cboNumbers.Add(intNumber.ToString)Next intNumbercboNumbers.SelectedItem = FirstEnd Sub
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
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 a combo box? List the three styles of combo boxes available in Visual Basic.
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
What are the three main reasons programmers use independent Sub procedures?
Question
What is the Math.Round function? Provide the function's syntax and define the arguments.
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?

A)decTotal = decSubtotal + GetSalesTax()
B)decSubtotal + GetSalesTax(decSubtotal)
C)decTotal = decSubtotal + GetSalesTax(decSubtotal)
D)decTotal = decSubtotal + GetSalesTax(decSubtotal As Decimal)
Question
How do the parameterList of a procedure header and the argumentList of a Call statement relate to each other?
Question
What is the difference between a Sub procedure and a Function procedure?
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
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
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
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?

A)Private Sub DisplayMessage(ByVal strItem As String, ByVal decPrice As Decimal)
B)Private Function DisplayMessage(ByVal strItem As String, ByVal decPrice As Decimal)
C)Private Sub DisplayMessage(ByRef strItem As String, ByRef decPrice As Decimal)
D)Private Sub DisplayMessage(ByVal strItem As String, ByRef decPrice As Decimal)
Question
Which of the following statements would invoke the DisplayMessage Sub procedure?

A)Call DisplayMessage()
B)Call DisplayMessage(strItemName, decItemPrice)
C)DisplayMessage(strItemName, decItemPrice)
D)Call DisplayMessage(strItemName, decItemPrice) As String
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
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
Sign up to unlock the cards in this deck!
Unlock Deck
Unlock Deck
1/60
auto play flashcards
Play
simple tutorial
Full screen (f)
exit full mode
Deck 7: Sub and Function Procedures
1
It is a common practice to begin a procedure's name with a(n)____.

A)noun
B)verb
C)adjective
D)adverb
B
2
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
B
3
Visual Basic allows you to specify that an argument in the Call statement is optional.
True
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 60 flashcards in this deck.
Unlock Deck
k this deck
5
Which of the following is a valid header for a procedure that is passed the number 9.75?

A)Private Function CalcSubtotal(ByVal intPrice As Integer) As Decimal
B)Private Function CalcSubtotal(ByRef intPrice As Integer) As Decimal
C)Private Function CalcSubtotal(ByVal decPrice As Decimal) As Decimal
D)Private Function CalcSubtotal(ByVal intPrice As Integer)
Unlock Deck
Unlock for access to all 60 flashcards in this deck.
Unlock Deck
k this deck
6
Math.Round(3.234,2)returns the number 3.24.
Unlock Deck
Unlock for access to all 60 flashcards in this deck.
Unlock Deck
k this deck
7
An event procedure is a Function procedure that is associated with a specific object and event.
Unlock Deck
Unlock for access to all 60 flashcards in this deck.
Unlock Deck
k this deck
8
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 60 flashcards in this deck.
Unlock Deck
k this deck
9
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 60 flashcards in this deck.
Unlock Deck
k this deck
10
An independent Sub procedure is a procedure that is independent of any object and event.
Unlock Deck
Unlock for access to all 60 flashcards in this deck.
Unlock Deck
k this deck
11
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 60 flashcards in this deck.
Unlock Deck
k this deck
12
The computer automatically processes an event procedure when the event occurs.
Unlock Deck
Unlock for access to all 60 flashcards in this deck.
Unlock Deck
k this deck
13
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 60 flashcards in this deck.
Unlock Deck
k this deck
14
Like a Sub procedure header,a Function procedure header includes the As dataType section.
Unlock Deck
Unlock for access to all 60 flashcards in this deck.
Unlock Deck
k this deck
15
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 60 flashcards in this deck.
Unlock Deck
k this deck
16
A Function procedure does not return a value after performing its assigned task.
Unlock Deck
Unlock for access to all 60 flashcards in this deck.
Unlock Deck
k this deck
17
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 60 flashcards in this deck.
Unlock Deck
k this deck
18
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 60 flashcards in this deck.
Unlock Deck
k this deck
19
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 60 flashcards in this deck.
Unlock Deck
k this deck
20
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?

A)Private Sub GetInfo(ByRef strName As String, ByRef intAge As Integer)
B)Private Sub GetInfo(ByRef strName, ByRef intAge)
C)Private Sub GetInfo(ByVal strName As String, ByVal intAge As Integer)
D)Private Sub GetInfo(ByVal strName, ByVal intAge)
Unlock Deck
Unlock for access to all 60 flashcards in this deck.
Unlock Deck
k this deck
21
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 60 flashcards in this deck.
Unlock Deck
k this deck
22
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 60 flashcards in this deck.
Unlock Deck
k this deck
23
The default combo box style in Visual Basic is ____.

A)Text
B)Simple
C)DropDown
D)DropDownList
Unlock Deck
Unlock for access to all 60 flashcards in this deck.
Unlock Deck
k this deck
24
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 60 flashcards in this deck.
Unlock Deck
k this deck
25
____ styles of combo boxes are available in Visual Basic.

A)Two
B)Three
C)Four
D)Five
Unlock Deck
Unlock for access to all 60 flashcards in this deck.
Unlock Deck
k this deck
26
Which of the following statements will determine the number of items in the list portion of the Department combo box?

A)cboDepartment.Count.Items
B)cboDepartment.Items.Count
C)lstDepartment.Items.Count
D)lstDepartment.Count.Items
Unlock Deck
Unlock for access to all 60 flashcards in this deck.
Unlock Deck
k this deck
27
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 60 flashcards in this deck.
Unlock Deck
k this deck
28
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 60 flashcards in this deck.
Unlock Deck
k this deck
29
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?

A)Private Function GetEndInventory(ByVal intBegin, ByVal intSales, ByVal intReturns) As Integer
B)Private Function GetEndInventory(ByVal intBegin As Integer, ByVal intSales As Integer, ByVal intReturns As Integer)
C)Private Function GetEndInventory(ByVal intBegin As Integer, ByVal intSales As Integer, ByVal intReturns As Integer, ByRef intEnd As Integer) As Integer
D)Private Function GetEndInventory(ByVal intBegin As Integer, ByVal intSales As Integer, ByVal intReturns As Integer) As Integer
Unlock Deck
Unlock for access to all 60 flashcards in this deck.
Unlock Deck
k this deck
30
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 60 flashcards in this deck.
Unlock Deck
k this deck
31
The syntax ____ displays a return value.

A)dblNewPrice = GetNewPrice(dblCurrentPrice)
B)lblNewPrice.Text = GetNewPrice(dblCurrentPrice).ToString("C2")
C)Dim dblNewPrice
D)dblTotalDue = intQuantity * GetNewPrice(dblCurrentPrice)
Unlock Deck
Unlock for access to all 60 flashcards in this deck.
Unlock Deck
k this deck
32
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 60 flashcards in this deck.
Unlock Deck
k this deck
33
Which of the following statements would invoke the GetEndInventory function and assign the function's return value to the intEnd variable?

A)Call GetEndInventory(intBegInv, intItemsSold, intReturned)
B)intEnd = Call GetEndInventory(intBegInv, intItemsSold, intReturned)
C)intEnd = GetEndInventory(intBegInv, intItemsSold, intReturned)
D)intEnd = GetEndInventory()
Unlock Deck
Unlock for access to all 60 flashcards in this deck.
Unlock Deck
k this deck
34
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 60 flashcards in this deck.
Unlock Deck
k this deck
35
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 60 flashcards in this deck.
Unlock Deck
k this deck
36
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 60 flashcards in this deck.
Unlock Deck
k this deck
37
The ____ keyword in a function header identifies the data type of the data being returned.

A)Is
B)DataType
C)As
D)Return
Unlock Deck
Unlock for access to all 60 flashcards in this deck.
Unlock Deck
k this deck
38
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 60 flashcards in this deck.
Unlock Deck
k this deck
39
The syntax ____ assigns a return value to a variable.

A)dblNewPrice = GetNewPrice(dblCurrentPrice)
B)lblNewPrice.Text = GetNewPrice(dblCurrentPrice).ToString
C)Dim dblNewPrice
D)dblNewPrice = dblCurrentPrice
Unlock Deck
Unlock for access to all 60 flashcards in this deck.
Unlock Deck
k this deck
40
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 60 flashcards in this deck.
Unlock Deck
k this deck
41
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 60 flashcards in this deck.
Unlock Deck
k this deck
42
' 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()
Unlock Deck
Unlock for access to all 60 flashcards in this deck.
Unlock Deck
k this deck
43
Private Sub frmMain_FormClosing(ByVal sender As Object,ByVal e As System.Windows.Forms.FormClosingEventArgs)Handles Me.FormClosing
' verify that the user wants to exit the application
Dim dlgButton As DialogResult
dlgButton = MessageBox.Show("Do you want to exit?",
"Sample Program")
' if the No button was selected,don't close the form
If dlgButton = DialogResult.Yes Then
e.Cancel = TrueEnd IfEnd SubPrivate Sub frmMain_Load(ByVal sender As Object, ByVal e As System.EventArgs) Handles Me.Load' fill combo box with values, then select default valueFor intNumber As Integer From 0 Thru 10cboNumbers.Add(intNumber.ToString)Next intNumbercboNumbers.SelectedItem = FirstEnd Sub
Unlock Deck
Unlock for access to all 60 flashcards in this deck.
Unlock Deck
k this deck
44
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 60 flashcards in this deck.
Unlock Deck
k this deck
45
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 60 flashcards in this deck.
Unlock Deck
k this deck
46
What is a combo box? List the three styles of combo boxes available in Visual Basic.
Unlock Deck
Unlock for access to all 60 flashcards in this deck.
Unlock Deck
k this deck
47
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 60 flashcards in this deck.
Unlock Deck
k this deck
48
What are the three main reasons programmers use independent Sub procedures?
Unlock Deck
Unlock for access to all 60 flashcards in this deck.
Unlock Deck
k this deck
49
What is the Math.Round function? Provide the function's syntax and define the arguments.
Unlock Deck
Unlock for access to all 60 flashcards in this deck.
Unlock Deck
k this deck
50
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?

A)decTotal = decSubtotal + GetSalesTax()
B)decSubtotal + GetSalesTax(decSubtotal)
C)decTotal = decSubtotal + GetSalesTax(decSubtotal)
D)decTotal = decSubtotal + GetSalesTax(decSubtotal As Decimal)
Unlock Deck
Unlock for access to all 60 flashcards in this deck.
Unlock Deck
k this deck
51
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 60 flashcards in this deck.
Unlock Deck
k this deck
52
What is the difference between a Sub procedure and a Function procedure?
Unlock Deck
Unlock for access to all 60 flashcards in this deck.
Unlock Deck
k this deck
53
Explain the difference between passing data by value and passing data by reference.
Unlock Deck
Unlock for access to all 60 flashcards in this deck.
Unlock Deck
k this deck
54
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 60 flashcards in this deck.
Unlock Deck
k this deck
55
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 60 flashcards in this deck.
Unlock Deck
k this deck
56
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 60 flashcards in this deck.
Unlock Deck
k this deck
57
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?

A)Private Sub DisplayMessage(ByVal strItem As String, ByVal decPrice As Decimal)
B)Private Function DisplayMessage(ByVal strItem As String, ByVal decPrice As Decimal)
C)Private Sub DisplayMessage(ByRef strItem As String, ByRef decPrice As Decimal)
D)Private Sub DisplayMessage(ByVal strItem As String, ByRef decPrice As Decimal)
Unlock Deck
Unlock for access to all 60 flashcards in this deck.
Unlock Deck
k this deck
58
Which of the following statements would invoke the DisplayMessage Sub procedure?

A)Call DisplayMessage()
B)Call DisplayMessage(strItemName, decItemPrice)
C)DisplayMessage(strItemName, decItemPrice)
D)Call DisplayMessage(strItemName, decItemPrice) As String
Unlock Deck
Unlock for access to all 60 flashcards in this deck.
Unlock Deck
k this deck
59
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 60 flashcards in this deck.
Unlock Deck
k this deck
60
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 60 flashcards in this deck.
Unlock Deck
k this deck
locked card icon
Unlock Deck
Unlock for access to all 60 flashcards in this deck.