Hi I need to edit this to suit Zambian phone number system which has 10 digit max and area code 260. I need help and will rely appreciate.
Thank you
vb
Private Sub txtPhone_Validate(Cancel As Boolean)
Dim strTemp As String
Dim strPhone As String
Dim strExtension As String
Dim intResult As Integer
Const DefaultAreaCode = "703"
'
' Remove all the grouping characters for
' now. We'll add them back in later.
'
strTemp = Replace(txtPhone, "(", "")
strTemp = Replace(strTemp, ")", "")
strTemp = Replace(strTemp, "-", "")
strTemp = Replace(strTemp, " ", "")
strTemp = Replace(strTemp, "X", "x")
'
' Break up the digits into the number and
' the extension, if any.
'
intResult = InStr(1, strTemp, "x", vbTextCompare)
If intResult > 0 Then
strExtension = Mid(strTemp, intResult + 1)
strPhone = Left(strTemp, intResult - 1)
Else
strPhone = strTemp
End If
If Left(strPhone, 1) = "1" Then
strPhone = Mid(strPhone, 2)
End If
If Len(strPhone) <> 7 And Len(strPhone) <> 10 Then
MsgBox "Please enter a valid telephone number.", vbExclamation
Cancel = True
Exit Sub
End If
'
' Prepend the default area code
'
If Len(strPhone) = 7 Then
strPhone = DefaultAreaCode & strPhone
End If
'
' Build the new phone number
'
txtPhone = "(" & Left(strPhone, 3) & ") " _
& Mid(strPhone, 4, 3) & "-" _
& Right(strPhone, 4)
'
' Add the extension, if any
'
If strExtension <> "" Then
txtPhone = txtPhone & " x" & strExtension
End If
End Sub
Mod Edit: Please use code tags when posting your code. Code tags are used like so =>

Thanks,
PsychoCoder