Question: Clearly Visual Basic: Programming with Microsoft Visual Basic 2012 Page 534 Exercise 3: MODIFY THIS: Open the Phone Solution (Phone Solution.sln) file contained in the
Clearly Visual Basic: Programming with Microsoft Visual Basic 2012
Page 534 Exercise 3: MODIFY THIS:
Open the Phone Solution (Phone Solution.sln) file contained in the ClearlyVB2012\Chap23\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.

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
Phone Numbers phone number with area code (111-222-3333): Numbers in file Formatted numbers e Save Display Exit X
Step by Step Solution
There are 3 Steps involved in it
Get step-by-step solutions from verified subject matter experts
