Create a function in a module to verify phone numbers in accordance with the North American Numbering Plan (NANP) rules. You should be able to pass in a phone number and the function will verify whether the phone number is valid. There are many ways to do this. My suggestion would be to have the function return a string value. If the string value returned is an empty string then the phone number is valid. If the phone number is invalid have the function return the string with the reason why the phone number is invalid. Below are some sample invalid phone numbers, representing each class of number:

  • (157) 836-8167 This number is invalid because Area Codes cannot begin with a 1 or 0.
  • (298) 731-6185 This number is invalid because the NANP is not assigning area codes with 9 as the second digit.
  • (678) 035-7598 This number is invalid because Exchange Codes cannot begin with a 1 or 0.
  • (752) 811-1375 This number is invalid because Exchange Codes cannot end with two 1s.
  • (265) 555-0128 This number is invalid because the Exchange Code is 555, and the Subscriber ID is within the range reserved for fictitious numbers.
  • (800) 555-0199 This number is the only 800 number with a 555 Exchange Code which is reserved for use as a fictitious number

Create a form suitable for verifying individual phone numbers.

Below as some screen shots of what is expected.

Verify a specific phone number manually entered against NANP rules Use a MakedTexbox for the phone number entry. Dont forget to strip the added characters ()-

See figure image. see image.

The above is a simplified way of accomplishing the task feel free to innovate. Results is what counts. see image.

Got time and want to learn more? Strictly voluntary. Instead of displaying the results to a message box display the results in a StatusStrip and change the StatusStrip background based on what the results are. I know there are plenty of old time programmers in this class. The old Status bar works in Dot Net code but learn how to use the new one. You will need to add a ToolStripStatusLabel to the StatusStrip and change the strip background color. Google will be your friend but a lot more fun than a message box. see image.

Academic Honesty!
It is not our intention to break the school's academic policy. Posted solutions are meant to be used as a reference and should not be submitted as is. We are not held liable for any misuse of the solutions. Please see the frequently asked questions page for further questions and inquiries.
Kindly complete the form. Please provide a valid email address and we will get back to you within 24 hours. Payment is through PayPal, Buy me a Coffee or Cryptocurrency. We are a nonprofit organization however we need funds to keep this organization operating and to be able to complete our research and development projects.