Está en la página 1de 1

Private KeyCodeToAvoid As MSForms.

ReturnInteger
Private Sub TextBoxData_KeyDown(ByVal KeyCode As MSForms.ReturnInteger, ByVal Sh
ift As Integer)
Set KeyCodeToAvoid = KeyCode
End 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 = KeyC
odeConstants.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.vbKey0
End Sub

También podría gustarte