código de máscaras de datas, cpf, rg em vba

Download Código de Máscaras de Datas, Cpf, Rg Em Vba

If you can't read please download the document

Upload: andersondreamerslove

Post on 10-Dec-2015

19 views

Category:

Documents


2 download

DESCRIPTION

nanan

TRANSCRIPT

Private KeyCodeToAvoid As MSForms.ReturnInteger Private Sub TextBoxData_KeyDown(ByVal KeyCode As MSForms.ReturnInteger, ByVal Shift As Integer) Set KeyCodeToAvoid = KeyCodeEnd Sub Private Sub TextBoxData_KeyPress(ByVal KeyAscii As MSForms.ReturnInteger) 'Limita a Qde de caracteres TextBoxData.MaxLength = 10 'para permitir que apenas nmeros sejam digitados If KeyAscii < Asc("0") Or KeyAscii > Asc("9") Then KeyAscii = 0 End If End Sub Private Sub TextBoxData_Change()'Formata : dd/mm/aaaa'no avalia se for backspace ou delete If Not (KeyCodeToAvoid = KeyCodeConstants.vbKeyBack Or KeyCodeToAvoid = KeyCodeConstants.vbKeyDelete) Then If Len(TextBoxData) = 2 Or Len(TextBoxData) = 5 Then TextBoxData.Text = TextBoxData.Text & "/" SendKeys "{End}", True End If End If 'zera o keycode KeyCodeToAvoid = KeyCodeConstants.vbKey0End Sub