如何在VB的3个text中输入正确的日期格式?

来源:百度知道 编辑:UC知道 时间:2024/06/21 18:15:57
条件:
在form1中放3个text:text1;text2;text3.分别依次代表小时;分钟;秒钟.
要求:[3个text只能输入数字)else msgbox"请输入正确的日期格式!"]
text1中可以接受的数字范围是00-23;
text2中可以接受的数字范围是01-59;
text3中可以接受的数字范围是01-59;
Update!
text2中可以接受的数字范围是00-59;
text3中可以接受的数字范围是00-59;

朋友,有什么问题还不知道的问我,或+我,我发程序给你,详细的给你说清楚
下面就是这个程序的代码:不清楚的问我

Private Sub Text1_Change()
If Val(Text1.Text) > 23 Then '判断输入的值是否大于23
MsgBox "请输入正确的日期格式!"
Text1.Text = ""
If Len(Text1.Text) = 2 Then Text2.SetFocus'输入时间完成,进入text2
End Sub

Private Sub Text1_KeyPress(KeyAscii As Integer)
If KeyAscii < Asc("0") Or KeyAscii > Asc("9") Then KeyAscii = 0
End Sub

Private Sub Text2_Change()
If Val(Text2.Text) > 59 Then
MsgBox "你输入的时间无效,请正确输入!"
Text2.Text = ""
If Len(Text2.Text) = 2 Then Text3.SetFocus
End Sub

Private Sub Text2_KeyPress(KeyAscii As Integer)
If KeyAscii < Asc("0") Or KeyAscii > Asc("9") Then KeyAscii = 0
End Sub

Private Sub Text3_Change()
If Val(Text3.Text) > 59 Then
MsgBox "你输入的时间无效,请正确输入!"
Text3.Text = ""
If