Question
Visual Basic 1: Exercise 9-2 Work with strings Open the application and add code to parse a name 1. Open the application thats in the
Visual Basic 1:
Exercise 9-2 Work with strings
Open the application and add code to parse a name
1. Open the application thats in the C:\VB 2015\Chapter 09\StringHandling directory. Within this project, youll find a form that accepts a name and a phone number from the user and provides buttons for parsing the name and editing the phone number.
2. Add code to parse the name when the user enters a name and clicks the Parse Name button. This code should work whether the user enters a first, middle, and last name or just a first and last name. It should also convert the parsed name so the first letter of each word is uppercase but the other letters are lowercase. The results should be displayed in a message box like this:
First Name:
Middle Name:
Last Name:
3. Test the application to see if it works. Try entering the name in all uppercase letters or all lowercase letters to make sure the parsed name is still displayed with only the first letters capitalized. When youre done, close the form. Use the methods of the String class to edit a phone number
4. Use the methods of the String class to edit a phone number when the user enters a phone number and clicks the Edit Phone Number button. This code should remove all special characters from the user entry so the number consists of 10 digits. Then, it should format the phone number with hyphens. These results should be displayed in a message box like the one that follows. For simplicity, you can assume that the user enters ten digits.
Entered:
Digits Only:
Standard Format:
5. Test the application with a variety of entry formats to make sure it works. When youre done, close the form.
Use the methods of the StringBuilder class to edit the phone number
6. Add an Imports statement for the System.Text namespace before the class declaration so you can refer to the StringBuilder class.
7. Copy all the statements that you wrote for step 4 except the MessageBox statement, and paste the statements before the MessageBox statement. Then, comment out the first set of statements. That way, youll be able to use the MessageBox statement with the second set of statements.
8. Modify the second set of statements so they use the StringBuilder class to do what step 4 requires.
9. Test the application to be sure it still works. Then, close the solution.
Step by Step Solution
There are 3 Steps involved in it
Step: 1
Get Instant Access to Expert-Tailored Solutions
See step-by-step solutions with expert insights and AI powered tools for academic success
Step: 2
Step: 3
Ace Your Homework with AI
Get the answers you need in no time with our AI-driven, step-by-step assistance
Get Started