Access开发培训
网站公告
·Access专家课堂QQ群号:151711184    ·Access快速开发平台下载地址及教程    ·欢迎加入Access专家课堂微信群!    ·如何快速搜索本站文章|示例|资料    
您的位置: 首页 > 技术文章 > Access数据库-模块/函数/VBA

access大写日期的函数

时 间:2009-02-09 08:40:53
作 者:郑家龙   ID:90  城市:上海
摘 要:大写日期的函数
正 文:

一组返回大写日期的函数,一个同事编的,有用的可以改善一下:
Public Function Dochangedate(strDate)
strDate = Format(strDate, "yy-mm-dd")
If Mid(strDate, 8, 1) = "0" Then
  Select Case Mid(strDate, 7, 2)
   Case 10
   Dochangedate = "零一十"
   Case 20
   Dochangedate = "零二十"
   Case 30
   Dochangedate = "零三十"
  End Select
  Else
     Select Case Mid(strDate, 8, 1)
     Case 1
     variable1 = "一"
     Case 2
     variable1 = "二"
     Case 3
     variable1 = "三"
     Case 4
     variable1 = "四"
     Case 5
     variable1 = "五"
     Case 6
     variable1 = "六"
     Case 7
     variable1 = "七"
     Case 8
     variable1 = "八"
     Case 9
     variable1 = "九"
  End Select
   Select Case Mid(strDate, 7, 1)
     Case 0
     variable2 = "零"
     Case 1
     variable2 = "一十"
     Case 2
     variable2 = "二十"
     Case 3
     variable2 = "三十"
  End Select
Dochangedate = variable2 & variable1
End If
End Function

Public Function Dochangemonth(strMonth)
strMonth = Format(strMonth, "yy-mm-dd")
If Mid(strMonth, 4, 1) = "0" Then
  Select Case Mid(strMonth, 5, 1)
   Case 1
   Dochangemonth = "零一"
   Case 2
   Dochangemonth = "零二"
   Case 3
   Dochangemonth = "零三"
   Case 4
   Dochangemonth = "四"
   Case 5
   Dochangemonth = "五"
   Case 6
   Dochangemonth = "六"
   Case 7
   Dochangemonth = "七"
   Case 8
   Dochangemonth = "八"
   Case 9
   Dochangemonth = "九"
  End Select
  Else
     Select Case Mid(strMonth, 5, 1)
     Case 0
     Dochangemonth = "零一十"
     Case 1
     Dochangemonth = "一十一"
     Case 2
     Dochangemonth = "一十二"
  End Select
End If
End Function

Public Function Dochangeyear(strYear)
strYear = Format(strYear, "yy-mm-dd")
  Select Case Mid(strYear, 2, 1)
    Case 0
    variable1 = "零"
    Case 1
    variable1 = "一"
    Case 2
    variable1 = "二"
    Case 3
    variable1 = "三"
    Case 4
    variable1 = "四"
    Case 5
    variable1 = "五"
    Case 6
    variable1 = "六"
    Case 7
    variable1 = "七"
    Case 8
    variable1 = "八"
    Case 9
    variable1 = "九"
  End Select
  Select Case Mid(strYear, 1, 1)
    Case 0
    variable2 = "零"
    Case 1
    variable2 = "一"
    Case 2
    variable2 = "二"
    Case 3
    variable2 = "三"
    Case 4
    variable2 = "四"
    Case 5
    variable2 = "五"
    Case 6
    variable2 = "六"
    Case 7
    variable2 = "七"
    Case 8
    variable2 = "八"
    Case 9
    variable2 = "九"
  End Select
  Dochangeyear = variable2 & variable1
End Function

Public Function Dochangeyear1(strYear)
strYear = Format(strYear, "yy-mm-dd")
  Select Case Mid(strYear, 2, 1)
    Case 0
    variable1 = "零"
    Case 1
    variable1 = "一"
    Case 2
    variable1 = "二"
    Case 3
    variable1 = "三"
    Case 4
    variable1 = "四"
    Case 5
    variable1 = "五"
    Case 6
    variable1 = "六"
    Case 7
    variable1 = "七"
    Case 8
    variable1 = "八"
    Case 9
    variable1 = "九"
  End Select
  Select Case Mid(strYear, 1, 1)
    Case 0
    variable2 = "零"
    Case 1
    variable2 = "一"
    Case 2
    variable2 = "二"
    Case 3
    variable2 = "三"
    Case 4
    variable2 = "四"
    Case 5
    variable2 = "五"
    Case 6
    variable2 = "六"
    Case 7
    variable2 = "七"
    Case 8
    variable2 = "八"
    Case 9
    variable2 = "九"
  End Select
  Dochangeyear1 = "二零" & variable2 & variable1
End Function


Access软件网官方交流QQ群 (群号:483923997)       Access源码网店

常见问答:

技术分类:

相关资源:

专栏作家

关于我们 | 服务条款 | 在线投稿 | 友情链接 | 网站统计 | 网站帮助