data format for field

Hello
how can a create fiekd in the form that will accept only data in specified format eg i would like to create field that will accept phone number in xxx-xxx-xxxx format

Thanks,
shri
shrihalbeAsked:
Who is Participating?
 
rkot2000Commented:
to add a control
menu : project-components -microsoft masked edit control.
drop a control on a form and press f1 for help. this is very simple control to use.


to clear masked control you should use this :

Public Sub ClearMaskEdBox(oMaskEdBox As MaskEdBox)
     Dim sTemp As String
     With oMaskEdBox
          sTemp = .Mask
          .Mask = ""
          .Text = ""
          .Mask = sTemp
     End With
End Sub

'Sample Call:
Private Sub cmdClear_Click()
     ClearMaskEdBox MaskEdBox1
     MaskEdBox1.SetFocus
End Sub
0
 
rkot2000Commented:
you should use masked control from microsoft.
0
 
shrihalbeAuthor Commented:
can you just explore that how can i used that one
i am really new in this feild.

thanks,
shri
0
Ultimate Tool Kit for Technology Solution Provider

Broken down into practical pointers and step-by-step instructions, the IT Service Excellence Tool Kit delivers expert advice for technology solution providers. Get your free copy now.

 
aikimarkCommented:
please be aware that you might want to explore third-party controls or add code to your masked edit control.  if the user presses the "-" character, they will not be repositioned to the start of the next series of SSN digits.
0
 
KarcOriginCommented:
Its simple,

You can use Mask edit control from microsoft.

Menu : Project- Components - Microsoft masked edit control

Add this code in Form Load -

Private Sub Form_Load()
    With MaskEdBox1
        .MaxLength = 12
        .Mask = "###-###-####"
    End With
End Sub


0
 
shrihalbeAuthor Commented:
thanks,
shri
0
Question has a verified solution.

Are you are experiencing a similar issue? Get a personalized answer when you ask a related question.

Have a better answer? Share it in a comment.

All Courses

From novice to tech pro — start learning today.