Academic Integrity: tutoring, explanations, and feedback — we don’t complete graded work or submit on a student’s behalf.

1) I want to clear out a label field called lbFinalCost so that it doesn’t displ

ID: 3737713 • Letter: 1

Question

1) I want to clear out a label field called lbFinalCost so that it doesn’t display in my app. I use the following statement: lblFinalCost.Clear() Why won’t this work?

How can I clear out the lblFinalCost?

2)What is wrong with the following code and how can you correct it?

Dim decNumberOfStudents As Decimal

decNumberOfStudents = txtNumberOfStudents

3) Assume I declared a variable decTripCost As Decimal and I computed the cost of a vacation by adding the airfare and the hotel cost and assigned the result of my calculation to the variable decTripCost. I want to display your vacation cost.

Why would the following code not work and how can you correct it? (2 points)

lblTripCost.Text = “The cost of your vacation is” decTripCost

Explanation / Answer

1)
Error : Clear method is not available for the Label property.
Clear cannot be applied on the lblFinalCost.

Correction : To set the label empty

lblFinalCost.Text=String.Empty


2)
Error : Since txtNumberOfStudents is of the TextBox type and decNumberOfStudents is of type Decimal
Mismatch of the data types.
Dim decNumberOfStudents As Decimal
decNumberOfStudents = txtNumberOfStudents

Correction :
'Call Text property of txtNumberOfStudents and convert the value to Decimal
'usign CDec

Dim decNumberOfStudents As Decimal
decNumberOfStudents = CDec(txtNumberOfStudents.Text)

3)
Correction :
'Use & ampersand as the concatenate operator for combining the
'string and decimal values and resultant as string and set to
'lblTripCost text property

lblTripCost.Text = "The cost of your vacation is" & decTripCost