7,762
社区成员
发帖
与我相关
我的任务
分享
Option Explicit
Private Sub Form_Load()
Dim col As New Collection
col.Add "零", "0"
col.Add "壹", "1"
col.Add "贰", "2"
col.Add "叁", "3"
col.Add "肆", "4"
col.Add "伍", "5"
col.Add "陆", "6"
col.Add "柒", "7"
col.Add "捌", "8"
col.Add "玖", "9"
col.Add "拾", "10"
Dim d As Date
d = "2007-010-0031"
'If Not IsDate(d) Then
' MsgBox "日期错误", vbCritical
' Exit Sub
'End If
Dim arr() As String, result As String
arr = Split(CStr(d), "-")
Dim i As Integer
For i = 1 To Len(arr(0))
result = result & col.Item(Mid(arr(0), i, 1))
Next i
result = result & "年"
'Debug.Print result
If Val(arr(1)) > 10 Then
result = result & "拾" & col.Item(Right(arr(1), 1)) & "月"
Else
result = result & col.Item(arr(1)) & "月"
End If
'Debug.Print result
If Val(arr(2)) > 19 Then
result = result & col.Item(Left(arr(2), 1)) & "拾" & col.Item(Right(arr(2), 1)) & "日"
ElseIf Val(arr(2)) > 10 Then
result = result & "拾" & col.Item(Right(arr(2), 1)) & "日"
Else
result = result & col.Item(arr(2)) & "日"
End If
Debug.Print result
End Sub