用法
'Udate(#11/21/2005#, 0) 显示 贰零零伍年壹拾壹月贰拾壹日 'Udate(#11/21/2005#, 1) 显示 贰零零伍 'Udate(#11/21/2005#, 2) 显示 壹拾壹 'Udate(#11/21/2005#, 3) 显示 贰拾壹
Public Function Udate(mDATE As Date, mYMD As Integer) As String Dim i As Integer, iD As Integer Dim strD(0 To 9) As String * 1, strDT(2) As String, strS As String strD(0) = "零" strD(1) = "壹" strD(2) = "贰" strD(3) = "叁" strD(4) = "肆" strD(5) = "伍" strD(6) = "陆" strD(7) = "柒" strD(8) = "捌" strD(9) = "玖" For i = mYMD + (mYMD <> 0) To mYMD + (mYMD <> 0) - (mYMD = 0) * 2 If i = 0 Then iD = Year(mDATE) strDT(i) = strD(iD \ 1000) & strD((iD \ 100) Mod 10) & strD((iD \ 10) Mod 10) & strD(iD Mod 10) Else If i = 1 Then iD = Month(mDATE) Else iD = Day(mDATE) If iD > 9 Then strS = "拾" Else strS = "" strDT(i) = strD(iD \ 10) & strS & strD(iD Mod 10) If iD > 9 And iD Mod 10 = 0 Then strDT(i) = "零" & Left$(strDT(i), 2) End If Next Select Case mYMD Case 0 Udate = strDT(0) & "年" & strDT(1) & "月" & strDT(2) & "日" Case Else Udate = strDT(mYMD - 1) End Select End Function
|