On Error GoTo st
If Len(Text1) = 8 And Mid(Text1, 5, 1) <> "-" And Mid(Text1, 8, 1) <> "-" Then
Text1 = Left(Text1, 4) + "-" + Mid(Text1, 5, 2) + "-" + Right(Text1, 2)
Text2.Text = Format(CDate(Format(Now, "YYYY-MM-DD")) - CDate(Text1.Text), "YYYY") - 1900
ElseIf Not (Len(Text1) = 10 And Mid(Text1, 5, 1) = "-" And Mid(Text1, 8, 1) = "-") Then
st: MsgBox ("职工出生日期输入有误,请检查更正!")
Text1.SetFocus
Text1.SelStart = 0
Text1.SelLength = Len(Text1)
Else
Text1 = Format(CDate(Text1.Text))
Text2.Text = Format(CDate(Format(Now, "YYYY-MM-DD")) - CDate(Text1.Text), "YYYY") - 1900
End If
[此贴子已经被作者于2007-10-20 0:57:56编辑过]