标题: 拜求 日期大小写转换 js开发的 [打印本页] 作者: guoxudong 时间: 2011-11-8 10:44 标题: 拜求 日期大小写转换 js开发的 比如 2011-11-11
贰零壹壹年 壹拾壹月 零壹 号
就支票上的写法作者: yanghua1900363 时间: 2011-11-8 15:44
'小写日期转大写
Function Date2Chinese(iDate As Date, iFormat As Byte) As String
'参数:iDate 指定日期;iFormat 指定格式,0 年月日,1年,2年月,3月日,4月,5日
Dim num(10)
Dim iYear
Dim iMonth
Dim iDay
Dim y, M, d
num(0) = "零"
num(1) = "壹"
num(2) = "贰"
num(3) = "叁"
num(4) = "肆"
num(5) = "伍"
num(6) = "陆"
num(7) = "柒"
num(8) = "捌"
num(9) = "玖"
iYear = Year(iDate)
iMonth = Month(iDate)
iDay = Day(iDate)
y = num(iYear \ 1000) + num((iYear \ 100) Mod 10) + num((iYear \ 10) Mod 10) + num(iYear Mod 10)
If iMonth >= 10 Then
If iMonth = 10 Then
M = "零" + "壹" + "拾"
Else
M = "壹" + "拾" + num(iMonth Mod 10)
End If
Else
M = "零" + num(iMonth Mod 10)
End If
If iDay >= 10 Then
If iDay = 10 Then
d = "零" + "壹" + "拾"
ElseIf iDay = 20 Or iDay = 30 Then
d = "零" + num(iDay \ 10) + "拾"
ElseIf iDay > 20 Then
d = num(iDay \ 10) + "拾" + num(iDay Mod 10)
Else
d = "壹" + "拾" + num(iDay Mod 10)
End If
Else
d = "零" + num(iDay Mod 10)
End If
Select Case iFormat
Case 0
Date2Chinese = y & "年" & M & "月" & d & "日"
Case 1
Date2Chinese = y & "年"
Case 2
Date2Chinese = y & "年" & M & "月"
Case 3
Date2Chinese = M & "月" & d & "日"
Case 4
Date2Chinese = M & "月"
Case 5
Date2Chinese = d & "日"
End Select
End Function 作者: todaynew 时间: 2011-11-8 16:36 本帖最后由 todaynew 于 2011-11-8 16:39 编辑
yanghua1900363 发表于 2011-11-8 15:44
'小写日期转大写
Function Date2Chinese(iDate As Date, iFormat As Byte) As String
'参数:iDate 指定日 ...
不需要这么多代码,呵呵。
Function strNew(strOld As String, str As String)
strOld = Replace(strOld, 0, "零")
For i = 1 To 9
strOld = Replace(strOld, i, Choose(i, "壹", "贰", "叁", "肆", "伍", "陆", "柒", "捌", "玖"))
Next
strOld = Replace(strOld, str, "年", 1, 1)
strOld = Replace(strOld, str, "月", 1, 1)
strOld = strOld & "日"
strNew = strOld
End Function 作者: yanghua1900363 时间: 2011-11-9 10:47
哇 代码又精简了 谢谢!作者: 轻风 时间: 2011-11-9 10:58