Notifications
Clear all
2024 - VBA & Macros
3
Posts
3
Usuários
0
Reactions
914
Visualizações
Topic starter
Ola, no codigo abaixo que esta funcionando , so tenho um inconveniente.
Ao digitar o cpf 123.456.789-10 apos entrar o digito 4 a tecla do teclado NumLk se apaga dai tenho que ligar ela novamente para poder continuar a digitar restante do cpf, .
Existe no codigo algum erro ?
Grato
Private Sub Txt_CPF_KeyPress(ByVal KeyAscii As MSForms.ReturnInteger) If Me.OptionButton2.Value = True Then Txt_CPF.MaxLength = 18 Select Case KeyAscii Case 8, 48 To 57 ' BackSpace e numericos If Len(Txt_CPF) = 2 Or Len(Txt_CPF) = 6 Then Txt_CPF.Text = Txt_CPF.Text & "." SendKeys "{End}", True End If If Len(Txt_CPF) = 10 Then Txt_CPF.Text = Txt_CPF.Text & "/" SendKeys "{End}", True End If If Len(Txt_CPF) = 15 Then Txt_CPF.Text = Txt_CPF.Text & "-" SendKeys "{End}", True End If Case Else ' o resto é travado KeyAscii = 0 End Select Else Txt_CPF.MaxLength = 14 Select Case KeyAscii Case 8, 48 To 57 ' BackSpace e numericos If Len(Txt_CPF) = 3 Or Len(Txt_CPF) = 7 Then Txt_CPF.Text = Txt_CPF.Text & "." SendKeys "{End}", True End If If Len(Txt_CPF) = 11 Then Txt_CPF.Text = Txt_CPF.Text & "-" SendKeys "{End}", True End If Case Else ' o resto é travado KeyAscii = 0 End Select End If End Sub
Postado : 31/03/2017 6:28 pm
Fuja do SendKeys
Existem mil maneiras de preparar Neston. Invente a sua!
http://www.youtube.com/ExpressoExcel
Postado : 31/03/2017 7:19 pm
manda a planilha
Se essa resposta te ajudou e resolveu o seu problema, clique no "joinha" ao lado de citar, e não esqueça de colocar o tópico como resolvido, clicando no ✓
Postado : 31/03/2017 8:29 pm