设为首页收藏本站Access中国

Office中国论坛/Access中国论坛

 找回密码
 注册

QQ登录

只需一步,快速开始

自定义日期显示函数

1970-1-1 08:00| 发布者: 海狸先生『文章』| 查看: 2093| 评论: 0

用法

'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

        
       

最新评论

QQ|站长邮箱|小黑屋|手机版|Office中国/Access中国 ( 粤ICP备10043721号-1 )  

GMT+8, 2025-4-4 16:05 , Processed in 0.057277 second(s), 16 queries .

Powered by Discuz! X3.3

© 2001-2017 Comsenz Inc.

返回顶部