Sos, Help!

acoombe
09-11-2003, 12:30 AM
This is what I have so far:

Dim strDash
Dim isNumeric
Dim blnNumber
Dim i As Integer


Private Sub Label1_Click(ByVal sender As System.Object, ByVal e As System.EventArgs) Handles lblInstruction.Click

End Sub

Private Sub btnReset_Click(ByVal sender As System.Object, ByVal e As System.EventArgs) Handles btnReset.Click
'Reset Phone Number to 999-999-9999.
txtPhoneNumber.Text = "999-999-9999"
MessageBox.Show("Enter Next Phone Number")
End Sub

Private Sub txtPhoneNumber_TextChanged(ByVal sender As System.Object, ByVal e As System.EventArgs) Handles txtPhoneNumber.TextChanged

End Sub

Private Sub Form1_Load(ByVal sender As System.Object, ByVal e As System.EventArgs) Handles MyBase.Load

End Sub

Private Sub btnVerify_Click(ByVal sender As System.Object, ByVal e As System.EventArgs) Handles btnVerify.Click
'This will verify if the data entered is a telephone number or not.
If txtPhoneNumber.Text.Length <> 12 Then
MessageBox.Show("Invalid Number Length")
End If

If txtPhoneNumber.Text > "--" Then
MessageBox.Show("Invalid Dashes")
End If

If isNumeric(txtPhoneNumber.Text.Chars(i)) = True Then
blnNumber = True
MessageBox.Show("This is a valid number.")
Else
MessageBox.Show("This is not a valid number.")
blnNumber = False
End If



End Sub
End Class

And here is the assingment I am working on: I am have trouble with the Verify Button and getting all the coding needed there....please someone, I am drowing here....! :/

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 solve the problem.


Here are a few hints to help you code the String methods:




Check that the user has entered two dashes in the appropriate spaces.

Break the string into 3 substrings, represented as 999,999, and 9999.

A Message box may by used for output.

Use the Visual Basic .NET IsNumber() function to determine whether each substring is a valid number. The function accepts one parameter and returns a True or False value. You can loop through each character in the string. The following may be a helpful resource:
IsNumber method

You may use the simpler .NET isNumeric as an alternative to IsNumber to do this assignment but do so with caution. It works only when applied to strings of length 1. Of course you then also need to check if dashes occur in the correct position in the string. I recommend setting the max number of characters in the text box string to 12. You will find Case statements, string methods, and FOR loops helpful in analyzing the validity of the input string. Also display a suitable message if the number is a valid number. Include a Reset button to re-initialize the form.

Garmour
09-11-2003, 02:34 AM
Go here for .NET questions (http://www.dotnetforums.net/)

EZ Archive Ads Plugin for vBulletin Copyright 2006 Computer Help Forum