VB中将日期转换为大写

jumay 2007-12-03 08:16:20
VB中如何将日期转换为大写,例如:2007-12-04转换后为贰零零柒年拾贰月肆日,请问VB代码怎样写
...全文
87 点赞 收藏 2
写回复
2 条回复
切换为时间正序
请发表友善的回复…
发表回复
zzyong00 2007-12-03
随手写的,不知有没有错
回复
zzyong00 2007-12-03
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
回复
发动态
发帖子
VB基础类
创建于2007-09-28

7450

社区成员

VB 基础类
申请成为版主
社区公告
暂无公告