程序代码:Private Sub Command1_Click()
If IsDate(Text1.Text) = False Then
MsgBox "输入的数据不是日期数据!"
Exit Sub
End If
Dim RSNX As String, RSSJ As Date
RSSJ = CDate(Text1.Text) '如果是数据表中的数据,连接数据库、数据表读取入司时间到变量 RSSJ 即可
RSNX = Format((Year(Date) - Year(RSSJ) + (Month(Date) - Month(RSSJ)) / 12 + (Day(Date) - Day(RSSJ)) / 365), "0.00") & "年"
Text2.Text = RSNX '如果要存储到入司年限字段,存储 RSNX 变量到 入司年限 字段就可以,不需要再啰嗦了吧。
End Sub很简单的。











