以下是一段没有经过测试的代码:function getDateStr(theDate as date) as string dim tmp as integer dim dText as string dim xx as integerfor xx=1 to 4 dtext=dtext+getintstr1(mid(format(thedate,"yyyy"),xx,1)) next dtext=dtext+"年" tmp=format(thedate,"mm") dtext=dtext+getintstr2(tmp)+getintstr1(tmp)+"月 tmp=format(thedate,"dd") dtext=dtext+getintstr2(tmp)+getintstr1(tmp)+"日 getdatestr=dtext end functionfunction getIntStr1(theInt as integer) as string ''此函数只能接受一位的数字 select case theint mod 10 case 0 getintstr1="零" case 1 getintstr1="一" case 2 getintstr1="二 case 3 getintstr1="三 case 4 getintstr1="四 case 5 getintstr1="五 case 6 getintstr1="六 case 7 getintstr1="七 case 8 getintstr1="八 case 9 getintstr1="九 end select end functionfunction getIntStr2(theInt as integer) as string if theint>=30 then getintstr2="卅 elseif theint>=20 then getintstr2="廿 elseif theint>=10 then getintstr2="十 endif end function如果需要时分秒,以此类推
来个短点的,直接copy试试num$ = " O一二三四五六七八九十" ‘(注意前面空格) d = "" '处理年份 For i = 1 To 4 d = d + Mid(num$, Val(Mid(Trim(Str(Year(Now))), i, 1)) + 2, 1) Next i '处理月份 If Month(Now) < 11 Then d = d + "年" + Mid(num$, Month(Now) + 2, 1) + "月" If Month(Now) = 11 Then d = d + "年" + "十一月" If Month(Now) = 12 Then d = d + "年" + "十二月" '处理日 If Day(Now) < 11 Then d = d + Mid(num$, Day(Now) + 1, 2) + "日" If Day(Now) > 10 And Day(Now) < 20 Then d = d + "十" + Trim(Mid(num$, Day(Now) - 10 + 1, 1)) + "日" If Day(Now) > 19 And Day(Now) < 30 Then d = d + "二十" + Trim(Mid(num$, Day(Now) - 19 + 1, 1)) + "日" If Day(Now) > 29 Then d = d + "三十" + Trim(Mid(num$, Day(Now) - 29 + 1, 1)) + "日" Text1.Text = d
为什么有超过3贴的限制?让我无法回贴! 全部代码如下,已经经过测试Function getDateStr(theDate As Date) As String Dim tmp As Integer Dim dText As String Dim xx As IntegerFor xx = 1 To 4 dText = dText + getIntStr1(Mid(Format(theDate, "yyyy"), xx, 1)) Next dText = dText + "年" tmp = Format(theDate, "m") dText = dText + getIntStr2(tmp) + IIf(tmp Mod 10 > 0, getIntStr1(tmp), "") + "月" tmp = Format(theDate, "d") dText = dText + getIntStr2(tmp) + IIf(tmp Mod 10 > 0, getIntStr1(tmp), "") + "日" getDateStr = dText End FunctionFunction getIntStr1(theInt As Integer) As String ''此函数只能接受一位的数字 Select Case theInt Mod 10 Case 0 getIntStr1 = "零" Case 1 getIntStr1 = "一" Case 2 getIntStr1 = "二" Case 3 getIntStr1 = "三" Case 4 getIntStr1 = "四" Case 5 getIntStr1 = "五" Case 6 getIntStr1 = "六" Case 7 getIntStr1 = "七" Case 8 getIntStr1 = "八" Case 9 getIntStr1 = "九" End Select End FunctionFunction getIntStr2(theInt As Integer) As String If theInt >= 30 Then getIntStr2 = "卅" ElseIf theInt >= 20 Then getIntStr2 = "廿" ElseIf theInt >= 10 Then getIntStr2 = "十" End If End Function
二00七年一月二十日
tmp = Format(Now, "YYYY年MM月DD日")
tmp = Replace(tmp, "0", "零")
tmp = Replace(tmp, "1", "一")
tmp = Replace(tmp, "2", "二")
tmp = Replace(tmp, "3", "三")
tmp = Replace(tmp, "4", "四")
tmp = Replace(tmp, "5", "五")
tmp = Replace(tmp, "6", "六")
tmp = Replace(tmp, "7", "七")
tmp = Replace(tmp, "8", "八")
tmp = Replace(tmp, "8", "九")
Text1.Text = tmp
dim tmp as integer
dim dText as string
dim xx as integerfor xx=1 to 4
dtext=dtext+getintstr1(mid(format(thedate,"yyyy"),xx,1))
next
dtext=dtext+"年"
tmp=format(thedate,"mm")
dtext=dtext+getintstr2(tmp)+getintstr1(tmp)+"月
tmp=format(thedate,"dd")
dtext=dtext+getintstr2(tmp)+getintstr1(tmp)+"日
getdatestr=dtext
end functionfunction getIntStr1(theInt as integer) as string
''此函数只能接受一位的数字
select case theint mod 10
case 0
getintstr1="零"
case 1
getintstr1="一"
case 2
getintstr1="二
case 3
getintstr1="三
case 4
getintstr1="四
case 5
getintstr1="五
case 6
getintstr1="六
case 7
getintstr1="七
case 8
getintstr1="八
case 9
getintstr1="九
end select
end functionfunction getIntStr2(theInt as integer) as string
if theint>=30 then
getintstr2="卅
elseif theint>=20 then
getintstr2="廿
elseif theint>=10 then
getintstr2="十
endif
end function如果需要时分秒,以此类推
d = ""
'处理年份
For i = 1 To 4
d = d + Mid(num$, Val(Mid(Trim(Str(Year(Now))), i, 1)) + 2, 1)
Next i
'处理月份
If Month(Now) < 11 Then d = d + "年" + Mid(num$, Month(Now) + 2, 1) + "月"
If Month(Now) = 11 Then d = d + "年" + "十一月"
If Month(Now) = 12 Then d = d + "年" + "十二月"
'处理日
If Day(Now) < 11 Then d = d + Mid(num$, Day(Now) + 1, 2) + "日"
If Day(Now) > 10 And Day(Now) < 20 Then d = d + "十" + Trim(Mid(num$, Day(Now) - 10 + 1, 1)) + "日"
If Day(Now) > 19 And Day(Now) < 30 Then d = d + "二十" + Trim(Mid(num$, Day(Now) - 19 + 1, 1)) + "日"
If Day(Now) > 29 Then d = d + "三十" + Trim(Mid(num$, Day(Now) - 29 + 1, 1)) + "日"
Text1.Text = d
全部代码如下,已经经过测试Function getDateStr(theDate As Date) As String
Dim tmp As Integer
Dim dText As String
Dim xx As IntegerFor xx = 1 To 4
dText = dText + getIntStr1(Mid(Format(theDate, "yyyy"), xx, 1))
Next
dText = dText + "年"
tmp = Format(theDate, "m")
dText = dText + getIntStr2(tmp) + IIf(tmp Mod 10 > 0, getIntStr1(tmp), "") + "月"
tmp = Format(theDate, "d")
dText = dText + getIntStr2(tmp) + IIf(tmp Mod 10 > 0, getIntStr1(tmp), "") + "日"
getDateStr = dText
End FunctionFunction getIntStr1(theInt As Integer) As String
''此函数只能接受一位的数字
Select Case theInt Mod 10
Case 0
getIntStr1 = "零"
Case 1
getIntStr1 = "一"
Case 2
getIntStr1 = "二"
Case 3
getIntStr1 = "三"
Case 4
getIntStr1 = "四"
Case 5
getIntStr1 = "五"
Case 6
getIntStr1 = "六"
Case 7
getIntStr1 = "七"
Case 8
getIntStr1 = "八"
Case 9
getIntStr1 = "九"
End Select
End FunctionFunction getIntStr2(theInt As Integer) As String
If theInt >= 30 Then
getIntStr2 = "卅"
ElseIf theInt >= 20 Then
getIntStr2 = "廿"
ElseIf theInt >= 10 Then
getIntStr2 = "十"
End If
End Function