21550.html

来自「VB技巧问答10000例,是一个教程」· HTML 代码 · 共 23 行

HTML
23
字号
<html>  <head>    <title>Re: Format(Now, &quot;ggge年m月d日&quot;) 找到解答了</title>  </head>  <body bgcolor="#FFFFFF" vlink="#808080">    <center>      <h1>Re: Format(Now, &quot;ggge年m月d日&quot;) 找到解答了</h1>    </center><hr size=7 width=75%><hr size=7 width=75%><p>Posted by <a href="mailto:sony@mail.cna.com.tw">求教者</a> on November 23, 1999 at 11:15:37:<p>In Reply to: <a href="21548.html">Format(Now, "ggge年m月d日")</a> posted by SuBird on November 23, 1999 at 09:45:31:<p>: Format(Now, "ggge年m月d日")<br>: 输出为:中华民国88年11月23日<br>: 若要输出中华民国八十八年十一月二十二日内的中文数字可能要自己作字串处理吧?!<p>谢谢你的解答, 我刚刚又参考了"VB实战网"下的<br>做了一些修改, 跑出来的效果还不错, 大家参考参考<p>Public Function CChineseDay(myDay As Date) As String<br>    Dim a As String<br>    Dim s As String<br>    <br>    a = Format(myDay, "ddmmee")<br>    <br>    s = "中华民国" & CChinese(Mid(a, 5)) & "年" & _<br>                     CChinese(Mid(a, 3, 2)) & "月" & _<br>                     CChinese(Left(a, 2)) & "日"<br>    CChineseDay = s<br>End Function<p><br>' 以下程式乃修改于 http://tacocity.com.tw/jaric/vb/simple/vbSimple4.htm<br>Private Function CChinese(StrEng As String) As String<br>     If Not IsNumeric(StrEng) Or StrEng Like "*.*" Or StrEng Like "*-*" Then<br>          If Trim(StrEng) <> "" Then MsgBox "无效的数字"<br>          CChinese = "": Exit Function<br>     End If<br>     <br>     Dim intLen As Integer, intCounter As Integer<br>     Dim strCh As String, strTempCh As String<br>     Dim strSeqCh1 As String, strSeqCh2 As String<br>     Dim strEng2Ch As String<br>     <br>     strEng2Ch = "零一二三四五六七八九"<br>     strSeqCh1 = " 十百千 十百千 十百千 十百千"<br>     strSeqCh2 = " 万亿兆"<br>     <br>     StrEng = CStr(CDec(StrEng))<br>     intLen = Len(StrEng)<br>     For intCounter = 1 To intLen<br>          strTempCh = Mid(strEng2Ch, Val(Mid(StrEng, intCounter, 1)) + 1, 1)<br>          ' 加上这条判断才能避免产生"一十二", 换成"十二"<br>          If intCounter = 1 And strTempCh = "一" And (intLen Mod 4) = 2 Then<br>               strTempCh = "十"<br>          ElseIf strTempCh = "零" And intLen <> 1 Then<br>               If Mid(StrEng, intCounter + 1, 1) = "0" Or (intLen - intCounter + 1) Mod 4 = 1 Then<br>                    strTempCh = ""<br>               End If<br>          Else<br>               strTempCh = strTempCh & Trim(Mid(strSeqCh1, intLen - intCounter + 1, 1))<br>          End If<br>          If (intLen - intCounter + 1) Mod 4 = 1 Then<br>               strTempCh = strTempCh & Mid(strSeqCh2, (intLen - intCounter + 1) \ 4 + 1, 1)<br>               If intCounter > 3 Then<br>                    If Mid(StrEng, intCounter - 3, 4) = "0000" Then strTempCh = _<br>                    Left(strTempCh, Len(strTempCh) - 1)<br>              End If<br>          End If<br>          strCh = strCh & Trim(strTempCh)<br>     Next<br>     CChinese = strCh<br>End Function<br><br><br><hr size=7 width=75%><p><a name="followups">Follow Ups:</a><br><ul><!--insert: 21550--></ul><!--end: 21550--><br><hr size=7 width=75%><p></body></html>

⌨️ 快捷键说明

复制代码Ctrl + C
搜索代码Ctrl + F
全屏模式F11
增大字号Ctrl + =
减小字号Ctrl + -
显示快捷键?