Visual Basic - Fecha

Life is soft - evento anual de software empresarial
 
Vista:

Fecha

Publicado por Javier (2 intervenciones) el 06/01/2001 00:00:00
Me gustaría saber como poder introducir
en una caja de texto la fecha en el formato
dd/mm/yy sin que el usuario ponga las "/"
Valora esta pregunta
Me gusta: Está pregunta es útil y esta claraNo me gusta: Está pregunta no esta clara o no es útil
0
Responder

RE:Fecha

Publicado por Christian A. Valeria Celedón (207 intervenciones) el 06/01/2001 00:00:00
Agrega el siguiente código a los eventos Change y KeyPress del cuadro de texto.

Private Sub Text1_Change()
If Not SeparadorFijo Then
If Len(Text1) = 2 Then Text1 = Text1 & "/"
If Len(Text1) = 5 Then Text1 = Text1 & "/"
Text1.SelStart = Len(Text1)
End If
End Sub

Private Sub Text1_KeyPress(KeyAscii As Integer)
If InStr(1, "0123456789", Chr(KeyAscii)) = 0 Then
KeyAscii = 0
Beep
End If
End Sub

Espero que te sirva...
Valora esta respuesta
Me gusta: Está respuesta es útil y esta claraNo me gusta: Está respuesta no esta clara o no es útil
0
Comentar

RE:Fecha

Publicado por Ariopolis (159 intervenciones) el 08/01/2001 00:00:00
Pon el siguiente código, así el usuario no se preocupará de tener que poner las barras:

Private Sub Text1_KeyPress(KeyAscii As Integer)
If KeyAscii <> vbKeyBack Then
If Len(Text1.Text) = 2 Then
Text1.Text = Text1.Text & "/"
End If
If Len(Text1.Text) = 5 Then
Text1.Text = Text1.Text & "/"
End If
Text1.SelStart = Len(Text1.Text)
End If

If (KeyAscii > vbKey9 Or KeyAscii < vbKey0) And KeyAscii <> vbKeyBack Then
KeyAscii = 0
End If
End Sub

Un saludo
Valora esta respuesta
Me gusta: Está respuesta es útil y esta claraNo me gusta: Está respuesta no esta clara o no es útil
0
Comentar

RE:Fecha

Publicado por Ariopolis (159 intervenciones) el 08/01/2001 00:00:00
AH!, la propiedad MaxLenght del Text1 ponla a 8.
Valora esta respuesta
Me gusta: Está respuesta es útil y esta claraNo me gusta: Está respuesta no esta clara o no es útil
0
Comentar