设为首页收藏本站Access中国

Office中国论坛/Access中国论坛

 找回密码
 注册

QQ登录

只需一步,快速开始

返回列表 发新帖
查看: 2461|回复: 5
打印 上一主题 下一主题

[模块/函数] 大写日期的函数

[复制链接]

点击这里给我发消息

跳转到指定楼层
1#
发表于 2002-11-21 01:17:00 | 只看该作者 回帖奖励 |倒序浏览 |阅读模式
一组返回大写日期的函数,一个同事编的,有用的可以改善一下:
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
分享到:  QQ好友和群QQ好友和群 QQ空间QQ空间 腾讯微博腾讯微博 腾讯朋友腾讯朋友
收藏收藏 分享分享 分享淘帖 订阅订阅

点击这里给我发消息

2#
 楼主| 发表于 2003-4-1 02:32:00 | 只看该作者
你能提供一个简单一点的吗?
3#
发表于 2004-3-30 02:06:00 | 只看该作者
虽然复杂了点,但正是我想要的,谢谢!!
4#
发表于 2004-3-31 01:57:00 | 只看该作者
Function FD(DT As Date)
    Dim dtStr As String
    Dim dfStr
    Dim YR, MT, DY
    dtStr = Year(DT)
    mtStr = "零一二三四五六七八九"
    For i = 1 To Len(dtStr)
        dfStr = dfStr & Mid(mtStr, Mid(dtStr, i, 1) + 1, 1)
    Next i
    MT = IIf(Len(Month(DT)) = 1, "0" & Month(DT), Month(DT))
    If Left(MT, 1) = 0 Then
        dfStr = dfStr & "年零" & Mid(mtStr, Mid(MT, 2, 1) + 1, 1)
    Else
        dfStr = dfStr & "年" & Mid(mtStr, Mid(MT, 1, 1) + 1, 1) & "十" & IIf(Mid(MT, 2, 1) = 0, "", Mid(mtStr, Mid(MT, 2, 1) + 1, 1))
    End If
    DY = IIf(Len(Day(DT)) = 1, "0" & Day(DT), Day(DT))
    If Left(DY, 1) = 0 Then
        dfStr = dfStr & "月零" & Mid(mtStr, Mid(DY, 2, 1) + 1, 1)
    Else
        dfStr = dfStr & "月" & Mid(mtStr, Mid(DY, 1, 1) + 1, 1) & "十" & IIf(Mid(DY, 2, 1) = 0, "", Mid(mtStr, Mid(DY, 2, 1) + 1, 1))
    End If
    FD = dfStr & "日"
End Function
5#
发表于 2004-5-8 00:02:00 | 只看该作者

  工欲善其事,必先利其器。
  时间有限,精力有限,看见这玩儿就想晕。
6#
发表于 2009-4-17 15:42:10 | 只看该作者
谢谢分享。收藏了。
您需要登录后才可以回帖 登录 | 注册

本版积分规则

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

GMT+8, 2024-11-14 03:54 , Processed in 0.082806 second(s), 30 queries .

Powered by Discuz! X3.3

© 2001-2017 Comsenz Inc.

快速回复 返回顶部 返回列表