Private Sub Command1_Click() s$ = "00年07月00日" '七个月 Debug.Print Fun(s)
s$ = "02年10月00日" '二年十个月 Debug.Print Fun(s)
s$ = "05年08月05日" '五年八个月零五日 Debug.Print Fun(s)
s$ = "03年04月00日" '三年四个月 Debug.Print Fun(s)
End Sub
Function Fun$(sDate$) y = Int(Mid(sDate, 1, 2)) m = Int(Mid(sDate, 4, 2)) d = Int(Mid(sDate, 7, 2)) yy = "" mm = "" dd = "" If y > 0 Then yy = toChs(Int(y)) & "年" End If
If m > 0 Then mm = toChs(Int(m)) & "个月" End If
If d > 0 Then If d < 10 Then dd = "零" End If dd = dd & toChs(Int(d)) & "日" End If
Fun$ = yy & mm & dd End Function
Function toChs(n) Chs = "一二三四五六七八九十" If n = 0 Then toChs = "" ElseIf n > 10 Then toChs = Mid(Chs, Int(n / 10), 1) & "十" & Mid(Chs, n Mod 10, 1) Else toChs = Mid(Chs, n, 1) End If