Configuração de tex...
 
Notifications
Clear all

Configuração de textbox

4 Posts
2 Usuários
0 Reactions
961 Visualizações
(@souzadenilson)
Posts: 96
Estimable Member
Topic starter
 

Utilizei o seguinte comando abaixo: Como proceder para que caso não digite valor ele retorne como ISENTO

Private Sub txt_CNPJCli_KeyPress(ByVal KeyAscii As MSForms.ReturnInteger)
txt_CNPJCli.Text = UCase(txt_CNPJCli)
txt_CNPJCli.SelStart = Len(txt_CNPJCli)
If txt_CNPJCli = " " Then
txt_CNPJCli = "ISENTO"
End If
Select Case KeyAscii
Case 8, 48 To 57
Me.txt_CNPJCli.MaxLength = 18 ' Quantidade máxima de caracteres no textbox CNPJ If Len(CNPJ) = 2 Then CNPJ = CNPJ + "."
If Len(txt_CNPJCli) = 6 Then txt_CNPJCli = txt_CNPJCli + "."
If Len(txt_CNPJCli) = 10 Then txt_CNPJCli = txt_CNPJCli + "/"
If Len(txt_CNPJCli) = 15 Then txt_CNPJCli = txt_CNPJCli + "-"
Case Else
KeyAscii = 0

End Select
'End Sub

End Sub

 
Postado : 21/03/2014 4:05 pm
(@fernandofernandes)
Posts: 43750
Illustrious Member
 

Não entendi, pois o código está no evento KeyPress (tecla precionada), se não "escrever" nada não gera o evento.
Dependendo da configuração de seu form, experimente, por exemplo, adicionar o if .. no evento Exit do textbox.

 
Postado : 21/03/2014 6:59 pm
(@souzadenilson)
Posts: 96
Estimable Member
Topic starter
 

Utilizei um checkacebox e quando eu marco o text box fica inativo, se eu desmarcar contunua escrito isento. Como fazer casi eu desmarque o text box ele fique ativo novamente para digitar

 
Postado : 22/03/2014 1:43 pm
(@souzadenilson)
Posts: 96
Estimable Member
Topic starter
 

Consegui resolver o problema em questão

 
Postado : 22/03/2014 3:00 pm