Thread: Phone numbers
View Single Post
  #1   Report Post  
Posted to microsoft.public.excel.programming
Patrick C. Simonds Patrick C. Simonds is offline
external usenet poster
 
Posts: 343
Default Phone numbers

I found the code below on-line (writen by Dick Kusleika) which works fine if
I click on another TextBox but if I click on my Finished Button the code
does not run. Any ideas what can be done to solve this proble?

Private Sub TextBox7_Exit(ByVal Cancel As MSForms.ReturnBoolean)

PhoneNum = Me.TextBox7.Text
If Len(PhoneNum) = 7 Then
FormatNum = "(360) " & Left(PhoneNum, 3) & "-" & Right(PhoneNum, 4)
ElseIf Len(PhoneNum) = 10 Then
FormatNum = "(" & Left(PhoneNum, 3) & ") " & Mid(PhoneNum, 4, 3) & _
"-" & Right(PhoneNum, 4)
Else
MsgBox "Not a Valid Phone Number"
Cancel = True
End If
Me.TextBox7.Text = FormatNum

End Sub