# Re: Format(Now, "ggge年m月d日") 找到解答了

Posted by 求教者 on November 23, 1999 at 11:15:37:

In Reply to: Format(Now, "ggge年m月d日") posted by SuBird on November 23, 1999 at 09:45:31:

: Format(Now, "ggge年m月d日")
: 输出为：中华民国88年11月23日
: 若要输出中华民国八十八年十一月二十二日内的中文数字可能要自己作字串处理吧？！

谢谢你的解答, 我刚刚又参考了"VB实战网"下的
做了一些修改, 跑出来的效果还不错, 大家参考参考

Public Function CChineseDay(myDay As Date) As String
Dim a As String
Dim s As String
a = Format(myDay, "ddmmee")
s = "中华民国" & CChinese(Mid(a, 5)) & "年" & _
CChinese(Mid(a, 3, 2)) & "月" & _
CChinese(Left(a, 2)) & "日"
CChineseDay = s
End Function

' 以下程式乃修改于 http://tacocity.com.tw/jaric/vb/simple/vbSimple4.htm
Private Function CChinese(StrEng As String) As String
If Not IsNumeric(StrEng) Or StrEng Like "*.*" Or StrEng Like "*-*" Then
If Trim(StrEng) <> "" Then MsgBox "无效的数字"
CChinese = "": Exit Function
End If
Dim intLen As Integer, intCounter As Integer
Dim strCh As String, strTempCh As String
Dim strSeqCh1 As String, strSeqCh2 As String
Dim strEng2Ch As String
strEng2Ch = "零一二三四五六七八九"
strSeqCh1 = " 十百千 十百千 十百千 十百千"
strSeqCh2 = " 万亿兆"
StrEng = CStr(CDec(StrEng))
intLen = Len(StrEng)
For intCounter = 1 To intLen
strTempCh = Mid(strEng2Ch, Val(Mid(StrEng, intCounter, 1)) + 1, 1)
' 加上这条判断才能避免产生"一十二", 换成"十二"
If intCounter = 1 And strTempCh = "一" And (intLen Mod 4) = 2 Then
strTempCh = "十"
ElseIf strTempCh = "零" And intLen <> 1 Then
If Mid(StrEng, intCounter + 1, 1) = "0" Or (intLen - intCounter + 1) Mod 4 = 1 Then
strTempCh = ""
End If
Else
strTempCh = strTempCh & Trim(Mid(strSeqCh1, intLen - intCounter + 1, 1))
End If
If (intLen - intCounter + 1) Mod 4 = 1 Then
strTempCh = strTempCh & Mid(strSeqCh2, (intLen - intCounter + 1) \ 4 + 1, 1)
If intCounter > 3 Then
If Mid(StrEng, intCounter - 3, 4) = "0000" Then strTempCh = _
Left(strTempCh, Len(strTempCh) - 1)
End If
End If
strCh = strCh & Trim(strTempCh)
Next
CChinese = strCh
End Function

Follow Ups: