Need help on Isnumeric function in VB.NET
Posted on 2003-10-27
Dear experts team:
My name is Larry Le and I am working on the project, which asks to verify the phone numbers when users enter into textbox. Below is more info about the project
Design and develop a program that validates the value a user enters into a TextBox control to ensure that the entry is a valid telephone number. The application should accept a maximum of 12 characters. When the user clicks a button, the program should determine if the entry is of the form 999-999-9999, where the character 9 represents any number.
If the entry is determined to be a telephone number, display an appropriate message, along with the separate substrings that compose the telephone number without the dashes. If the entry is not a telephone number, then display a message as to the reason why the entry is not a valid telephone number, clear the TextBox control and set focus to the TextBox control. Use String class methods to
Here is my codes for the program:
Private Sub cmdVerify_Click(ByVal sender As System.Object, ByVal e As System.EventArgs) Handles cmdVerify.Click
Dim Num As String
Num = "12"
If IsNumeric(Num) = True Then
txtTextBox1.Text = IsNumeric(Num)
txtTextBox1.Text = txtTextBox1.Text
MsgBox("Your number below is valided")
MsgBox("Your number below is invalid")
Private Sub cmdReset_Click(ByVal sender As System.Object, ByVal e As System.EventArgs) Handles cmdReset.Click
txtTextBox1.Text = "999-999-9999"
MsgBox("Please Enter Next Number")
Private Sub cmdQuit_Click(ByVal sender As System.Object, ByVal e As System.EventArgs) Handles cmdQuit.Click
MsgBox("Please come back again")
Based on the codes above, it lets me key in anything in textbox. However, if possible, Can you help me with the following condidion, I like
1. Users enter numbers into textbox with two dashes in the appropriate spaces and it breaks the string into three substrings, For example, 408-345-2323. If users enter right format as 408-345-2323, then message box display "Number Validaded". If users enter wrong format (without dashes in between) as 4083452323, then message box display "Number inValid because missing two dashes".
2. Users can enter combination text and numbers, however, as soon as users click Verify botton, message displays "This is not numbers".
Thanks in advance