Notifications
Clear all

[Resolvido] Autocompletar a data em Textbox

3 Posts
3 Usuários
1 Reactions
1,315 Visualizações
(@neri-s)
Posts: 0
New Member
Topic starter
 

Alguém tem um comando que autocompletar a data em Textbox. Exemplo: Digito "04/05" e ele automaticamente coloca "04/05/2021"

 

 
Postado : 04/05/2021 7:08 am
(@anderson)
Posts: 0
New Member
 

https://youtu.be/DbtB8bWJkM8

 

Private Sub TextBox1_Change()
If Len(Me.TextBox1.Text) = 5 Then

Me.TextBox1.Text = Me.TextBox1.Text & "/" & Year(Date)


End If


End Sub
Este post foi modificado 3 anos atrás por Anderson
 
Postado : 04/05/2021 9:14 am
NERI S reacted
(@gilbertol)
Posts: 0
New Member
 

Data e hora atualizado a cada dígito inserido!

 


Private Sub txtData_KeyPress(ByVal KeyAscii As MSForms.ReturnInteger)
Me.txtData.MaxLength = 10 ' Quantidade máxima de caracteres no textbox Data
Select Case KeyAscii
Case 8, 48 To 57
If Len(txtData) = 2 Then txtData = txtData + "/"
If Len(txtData) = 5 Then txtData = txtData + "/2021"
If Len(txtData) = 10 Then txtHora.SetFocus
Case Else
KeyAscii = 0
End Select
End Sub

Private Sub txtData_Change()
If Len(txtData) = 5 Then txtData = txtData + "/2021"
If Len(txtData) = 10 Then txtHora.SetFocus
End Sub

Private Sub txtHora_KeyPress(ByVal KeyAscii As MSForms.ReturnInteger)
Me.txtHora.MaxLength = 8 ' Quantidade máxima de caracteres no textbox Data
Select Case KeyAscii '08h20min
Case 8, 48 To 57
If Len(txtHora) = 2 Then txtHora = txtHora + "h"
If Len(txtHora) = 5 Then txtHora = txtHora
If Len(txtHora) = 8 Then cmdPositiva.SetFocus
Case Else
KeyAscii = 0
End Select
End Sub
Private Sub txtHora_Change()
If Len(txtHora) = 2 Then txtHora = txtHora + "h"
If Len(txtHora) = 5 Then txtHora = txtHora
If Len(txtHora) = 5 Then cmdPositiva.SetFocus
End Sub
Este post foi modificado 3 anos atrás por GilbertoL
 
Postado : 11/05/2021 8:09 pm