PDA

View Full Version : adapting number code to incorporate () - -



LearningEXL
04-09-2015, 01:26 AM
i have a code that allows only numbers into a textbox


Private Sub Txt_Office_No2_KeyPress(ByVal KeyAscii As MSForms.ReturnInteger)Select Case KeyAscii
Case Asc("0") To Asc("9")
Case Asc("-")
If InStr(1, Me.Txt_Office_No2.Text, "-") > 0 Or Me.Txt_Office_No2.SelStart > 0 Then
KeyAscii = 0
End If
' Case Asc(".")
' If InStr(1, Me.Txt_Office_No2.Text, ".") > 0 Then
' KeyAscii = 0
' End If
Case Else
KeyAscii = 0
End Select
End Sub

but what id like to do is adapt this to change a mobile number from 01234123123 to (01234)123-123