Type my_case_date
my_case_year As String
my_case_month As String
my_case_daily As String
End Type
Public Function number_case_hz(my_str_num As String) As String
If IsNull(my_str_num) Then
MsgBox "錯誤:不可轉入空值", vbOKOnly, "err_info"
Else
Select Case my_str_num
Case "0": number_case_hz = "零"
Case "1": number_case_hz = "壹"
Case "2": number_case_hz = "貳"
Case "3": number_case_hz = "毿"
Case "4": number_case_hz = "肆"
Case "5": number_case_hz = "伍"
Case "6": number_case_hz = "陸"
Case "7": number_case_hz = "柒"
Case "8": number_case_hz = "捌"
Case "9": number_case_hz = "玖"
End Select
End If
End Function
Public Function my_case_date(my_date As Date, my_info_hz As Boolean) As my_case_date
If IsNull(my_date) Or IsNull(my_info_hz) Then
MsgBox "錯誤:不可轉入空值", vbOKOnly, "err_info"
Exit Function
End If
Dim str_case_date As String
Dim my_date_year As String
Dim my_date_month As String
Dim my_date_daily As String
Dim my_len As Integer
With my_case_date
.my_case_year = ""
.my_case_month = ""
.my_case_daily = ""
End With
If my_info_hz = fasle Then
With my_case_date
.my_case_year = my_date_year
.my_case_month = my_date_month
.my_case_daily = my_date_daily
End With
Else
my_len = 1
While my_len <= 4
With my_case_date
.my_case_year = .my_case_year + number_case_hz(Mid(my_date_year, my_len, 1))
End With
my_len = my_len + 1
Wend
my_len = 1
If CInt(my_date_month) < 10 Then
While my_len <= 2
my_case_date.my_case_month = my_case_date.my_case_month + number_case_hz(Mid(my_date_month, my_len, 1))
my_len = my_len + 1
Wend
Else
If CInt(my_date_month) = 10 Then
my_case_date.my_case_month = "壹拾"
Else
If CInt(my_date_month) = 11 Then
my_case_date.my_case_month = "壹拾壹"
Else
If CInt(my_date_month) = 12 Then
my_case_date.my_case_month = "壹拾貳"
End If
End If
End If
End If
my_len = 1
If CInt(my_date_daily) < 10 Then
While my_len <= 2
my_case_date.my_case_daily = my_case_date.my_case_daily + number_case_hz(Mid(my_date_daily, my_len, 1))
my_len = my_len + 1
Wend
Else
If CInt(my_date_daily) = 10 Then
my_case_date.my_case_daily = "壹拾"
Else
If (CInt(my_date_daily) < 20 And CInt(my_date_daily) > 10) Or (CInt(my_date_daily) < 30 And CInt(my_date_daily) > 20) Then
my_case_date.my_case_daily = number_case_hz(Left(my_date_daily, 1)) + "拾" + number_case_hz(Right(my_date_daily, 1))
Else
If CInt(my_date_daily) = 20 Then
my_case_date.my_case_daily = "貳拾"
Else
If CInt(my_date_daily) = 30 Then
my_case_date.my_case_daily = "毿拾"
Else
If CInt(my_date_daily) = 31 Then
my_case_date.my_case_daily = "毿拾壹"
End If
End If
End If
End If
End If
End If
End If
End Fu
這是最終效果,專門為支票的格式處理過的,而不是一般的通用日期,大寫轉換,現在可以加一個參數,來實現分段輸出數字和漢字格式。