Start = Len(Text1.Text)
End If
End If
End If
''---------------------------------------------------------------------------
''日期输入的控制。
''---------------------------------------------------------------------------
If Len(Text1.Text) = 9 Then
If Right((Text1.Text), 1) <> "0" And Right((Text1.Text), 1) <> "1" And _
Right((Text1.Text), 1) <> "2" And Right((Text1.Text), 1) <> "3" Then
If Right((Text1.Text), 1) = "4" Or Right((Text1.Text), 1) = "5" Or _
Right((Text1.Text), 1) = "6" Or Right((Text1.Text), 1) = "7" Or _
Right((Text1.Text), 1) = "8" Or Right((Text1.Text), 1) = "9" Then
a = Right((Text1.Text), 1)
Text1.Text = Left((Text1.Text), 8) + "0" + a
Text1.SelStart = Len(Text1.Text)
''Exit Sub
''日期小于10时下面字符长度为10的判断当然是正确的。让它执行又如何?
Else
Text1.Text = Left((Text1.Text), Len(Text1.Text) - 1)
Text1.SelStart = Len(Text1.Text)
End If
End If
End If
''当要修改日期的最后一位时的控制。
If Len(Text1.Text) = 10 Then
b = Left(Right(Text1.Text, 5), 2) ''取月份值,用于下面的日期正确性判断!
c = Left(Text1.Text, 4) ''取年份值,用于下面的日期正确性判断!
If Right((Text1.Text), 1) <> "0" And Right((Text1.Text), 1) <> "1" And _
Right((Text1.Text), 1) <> "2" And Right((Text1.Text), 1) <> "3" And _
Right((Text1.Text), 1) <> "4" And Right((Text1.Text), 1) <> "5" And _
Right((Text1.Text), 1) <> "6" And Right((Text1.Text), 1) <> "7" And _
Right((Text1.Text), 1) <> "8" And Right((Text1.Text), 1) <> "9" Then
Text1.Text = Left((Text1.Text), Len(Text1.Text) - 1)
Text1.SelStart = Len(Text1.Text)
End If ''限制非法字符的输入。
If Right(Text1.Text, 2) = "00" Then
Text1.Text = Left((Text1.Text), Len(Text1.Text) - 2)
Text1.SelStart = Len(Text1.Text)
End If ''限制日期不能为0
If (b = "01" And Val(Right(Text1.Text, 2)) > 31) Or _
(b = "03" And Val(Right(Text1.Text, 2)) > 31) Or _
(b = "05" And Val(Right(Text1.Text, 2)) > 31) Or _
(b = "07" And Val(Right(Text1.Text, 2)) > 31) Or _
(b = "08" And Val(Right(Text1.Text, 2)) > 31) Or _
(b = "10" And Val(Right(Text1.Text, 2)) > 31) Or _
(b = "12" And Val(Right(Text1.Text, 2)) > 31) Then
Text1.Text = Left((Text1.Text), Len(Text1.Text) - 2)
Text1.SelStart = Len(Text1.Text)
End If ''当月份为大月份时日期不能大于31。
If (b = "04" And Val(Right(Text1.Text, 2)) > 30) Or _
(b = "06" And Val(Right(Text1.Text, 2)) > 30) Or _
(b = "09" And Val(Right(Text1.Text, 2)) > 30) Or _
(b = "11" And Val(Right(Text1.Text, 2)) > 30) Then
Text1.Text = Left((Text1.Text), Len(Text1.Text) - 2)
Text1.SelStart = Len(Text1.Text)
End I