Visual Basic provides the Mid statement for replacing a specified number of characters in a string with another string. The statement’s syntax is Mid(targetString, start[, count]) = replacementString. In the syntax, the targetString argument is the string in which you want characters replaced, and replacementString contains the replacement characters. The start argument is the position of the first character you want replaced in the targetString. Te first character in the targetString is in position 1; the second is in position 2, and so on. The optional count argument specifies the number of characters to replace in the targetString. If the count argument is omitted, the Mid statement replaces the lesser of either the number of characters in the replacementString or the number of characters in the targetString from position start through the end of the targetString. Open the Area Code Solution (Area Code Solution.sln) file contained in the VB2010\ Chap08\Area Code Solution folder. The interface allows the user to enter a phone number, including the area code. Code the Change Area Code button’s Click event procedure so that it first verifies whether the phone number is in the proper format. If the format is valid, the procedure should use the Mid statement to change the area code to 800 before displaying the phone number in the lblNew control. Save the solution and then start and test the application. Close the Code Editor window and then close the solution.
Already registered? Login
Not Account? Sign up
Enter your email address to reset your password
Back to Login? Click here