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:
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.