Question: More Visual Basic. Any help would be appreciated. Here's the code from the solution with what is required... ' Name: Phone Project ' Purpose: Save

More Visual Basic. Any help would be appreciated.

More Visual Basic. Any help would be appreciated. Here's the code from

Here's the code from the solution with what is required...

' Name: Phone Project ' Purpose: Save phone numbers to a sequential access file and ' display the file's contents and the formatted phone numbers ' Programmer: on

Public Class frmMain

Private Sub btnExit_Click(sender As Object, e As EventArgs) Handles btnExit.Click Me.Close() End Sub

Private Sub txtPhone_KeyPress(sender As Object, e As KeyPressEventArgs) Handles txtPhone.KeyPress ' allows the text box to accept numbers, the hyphen, and the Backspace key

If (e.KeyChar "9") AndAlso e.KeyChar "-" AndAlso e.KeyChar ControlChars.Back Then e.Handled = True End If End Sub

Private Sub txtPhone_TextChanged(sender As Object, e As EventArgs) Handles txtPhone.TextChanged lblFileContents.Text = String.Empty lblFormattedNumbers.Text = String.Empty End Sub

Private Sub btnSave_Click(sender As Object, e As EventArgs) Handles btnSave.Click ' saves a valid phone number to a sequential access file

Dim strPhone As String Dim outFile As IO.StreamWriter

strPhone = txtPhone.Text.Trim

' determine whether phone entry is in the following format: ' three digits, a hyphen, three digits, a hyphen, and four digits ' if the format is valid, remove the hyphens and then write the ' phone number to the phoneNumbers.txt file; otherwise, ' display an appropriate message

' clear the txtPhone control, then set the focus txtPhone.Text = String.Empty txtPhone.Focus() End Sub

Private Sub btnDisplay_Click(sender As Object, e As EventArgs) Handles btnDisplay.Click ' displays the phone numbers contained in the file ' also displays the phone numbers after inserting hyphens

Dim inFile As IO.StreamReader Dim strPhone As String

' clear previous phone numbers from the labels lblFileContents.Text = String.Empty lblFormattedNumbers.Text = String.Empty

' determine whether the phoneNumbers.txt file exists; if the ' file exists, display each phone number in the lblFileContents control ' also display each phone number, with the appropriate hyphens inserted, ' in the lblFormattedNumbers control ' if the file does not exist, display an appropriate message End Sub End Class

For reference, here's a link to download the Solution.

https://1drv.ms/u/s!AmC8c2tlK5loyG4pyIriDDJ7kE7a

Open the Phone Solution (Phone Solution.sln) file contained in the ClearlyVB20121Chap23 Phone Solution folder. Open the designer and Code Editor windows. Use the comments in the btnSave_Click and btnDisplay_Click procedures to finish coding the application. Save the solution and then start the application. Test the application using the following phone numbers: 1-234-567890 and 999-888-1111. Close the Code Editor window and then close the solution. btnDisplay_Click applicatone applicationSave the solution

Step by Step Solution

There are 3 Steps involved in it

1 Expert Approved Answer
Step: 1 Unlock blur-text-image
Question Has Been Solved by an Expert!

Get step-by-step solutions from verified subject matter experts

Step: 2 Unlock
Step: 3 Unlock

Students Have Also Explored These Related Databases Questions!