Exam 8: String Manipulation

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

Assume that the data for salary is entered with both a dollar symbol and a space. Which of the following instructions will remove the dollar symbol?

Free
(Multiple Choice)
4.7/5
(24)
Correct Answer:
Verified

A

You should assign shortcut keys to every menu item.

Free
(True/False)
4.7/5
(39)
Correct Answer:
Verified

False

Case-Based Critical Thinking Questions Case 1 - Human Resources Application An application used by the Human Resources (HR) department needs to be improved. You need to use various string manipulation properties and methods to ensure all data entered by a user is accurate and stored correctly. In order to remove both dashes from the SSN, you should first ____.

Free
(Multiple Choice)
4.8/5
(32)
Correct Answer:
Verified

C

Write the Visual Basic statement that uses the Contains method to determine whether the strEmployeeCode variable contains the string "NC" (entered in uppercase). Assign the method's return value to a Boolean variable named blnIsNC .

(Essay)
4.9/5
(26)

To insert characters within a string, you use the ____ method.

(Multiple Choice)
4.7/5
(33)

The ____ method returns an integer that represents the location of the subString within the string.

(Multiple Choice)
4.8/5
(39)

The strPhone variable contains a 10-digit phone number. If the string stored in the strPhone variable begins with the "336" area code, display the phone number in the lblPhone control's Text property. Use the StartsWith method.

(Essay)
4.9/5
(32)

Assume that a text box named PhoneNumberTextBox appears on a form and contains the phone number 414-555-5555. What value will display for the length of the phone number text box?

(Multiple Choice)
4.7/5
(29)

Programmers use the ____ property of the menu element to refer to the menu element in code.

(Multiple Choice)
4.9/5
(35)

If an application expects the user to enter a seven-digit phone number or a five-digit ZIP code, the application's code should verify that the user entered the required number of characters.

(True/False)
4.8/5
(28)

Problems - Correcting Logic and Code Errors The following sample of code contains errors. Rewrite the incorrect statements to correct all errors. Private Sub btnDisplay_Click(ByVal sender As Object, ByVal e As System.EventArgs) Handles btnDisplay.Click ' displays a pay rate based on an employee's code ' Full Time employee pay rate is 11.50. Part Time ' employee pay rate for those working more than 30 hours ' is 10.50, otherwise it is 9.50 Dim strEmpCode As String Dim decPayRate As Integer strCode = txtEmpCode.Text.Snip ' validate the employee code If strEmpCode = "FT##" Then decPayRate = 11.50 ElseIf strEmpCode Like "PT30##" Then decPayRate = 9.50 Else decPayRate = 10.50 End If ' display pay rate lblPayRate.Text = decPayRate.ToString("N2") End Sub

(Essay)
4.9/5
(34)

Problems - Correcting Logic and Code Errors The following sample of code contains errors. Rewrite the incorrect statements to correct all errors. Private Sub btnDisplay_Click(ByVal sender As Object, ByVal e As System.EventArgs) Handles btnDisplay.Click ' displays type of vehicle for the code entered by user Const strLENGTH_MSG As String = "The code must contain four characters." Const strTYPE_MSG As String = "The last character in the code must be C, T, or V." Dim strCode As String Dim strLastChar As String strCode = txtCode.Text.ToLower ' determine whether code contains exactly 4 characters If strCode.Chars lblType.Text = String.Empty MessageBox.Show(strLENGTH_MSG, "Code", MessageBoxButtons.OK, MessageBoxIcon.Information) Else ' determine whether the last character is valid strLastChar = strCode.Substring(4) Select Case strCode Case "C" lblType.Text = "Car" Case "T" lblType.Text = "Truck" Case "V" lblType.Text = "Van" Case Else lblType.Text = String.Empty MessageBox.Show(strType_MSG, "Type", MessageBoxButtons.OK, MessageBoxIcon.Information) End If End If End Sub

(Essay)
4.9/5
(28)

____ keys appear to the right of a menu item and allow you to select an item without opening the menu.

(Multiple Choice)
4.8/5
(36)

Case-Based Critical Thinking Questions Case 1 - Human Resources Application An application used by the Human Resources (HR) department needs to be improved. You need to use various string manipulation properties and methods to ensure all data entered by a user is accurate and stored correctly. The users of the HR application have entered some employee Social Security numbers (SSNs) with dashes (such as 222-33-4444) and some without dashes (such as 222334444). You need to remove all dashes from any SSN that contains dashes. You will use the ____ method to edit the code so that only numeric characters are stored.

(Multiple Choice)
4.9/5
(34)

To remove characters from only the beginning of a string, use the ____ method.

(Multiple Choice)
4.8/5
(40)

The txtGrade control contains the string "95%". Write the Visual Basic statement to remove the percent sign from the txtGrade control as well as convert the contents of the control to a Decimal number. Assign the result to the decGrade variable. Use the TrimEnd method.

(Essay)
4.9/5
(40)

The strState variable should contain two uppercase letters. Which of the following statements determines whether the variable contains a valid state?

(Multiple Choice)
4.8/5
(30)

Menu title captions should be one word only and entered using uppercase letters.

(True/False)
4.7/5
(38)

A character's ____ is an integer that indicates the character's position in the string.

(Multiple Choice)
4.8/5
(32)

Neither the Trim method nor the Remove method removes any characters from the original string.

(True/False)
4.8/5
(28)
Showing 1 - 20 of 60
close modal

Filters

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