设为首页收藏本站Access中国

Office中国论坛/Access中国论坛

 找回密码
 注册

QQ登录

只需一步,快速开始

返回列表 发新帖
查看: 1666|回复: 4
打印 上一主题 下一主题

[模块/函数] 实现日期大写显示

[复制链接]
1#
发表于 2002-10-4 19:51:00 | 显示全部楼层
呵呵,站長真仔細呀,把判斷十以上的月份處理都寫上了。可有的時間,人家不須要您搞的這樣復雜呀。
http://www.office-cn.net/bbs/dispbbs.asp?boardID=2&RootID=14523&ID=14523
我作的同你的相比怎樣?

[此贴子已经被HG于2002-10-4 11:51:19编辑过]

2#
发表于 2002-10-7 16:40:00 | 显示全部楼层
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

str_case_date = CStr(Format(my_date, "yyyy/mm/dd"))
my_date_year = Left(str_case_date, 4)
my_date_month = Mid(str_case_date, 6, 2)
my_date_daily = Right(str_case_date, 2)

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
這是最終效果,專門為支票的格式處理過的,而不是一般的通用日期,大寫轉換,現在可以加一個參數,來實現分段輸出數字和漢字格式。
您需要登录后才可以回帖 登录 | 注册

本版积分规则

QQ|站长邮箱|小黑屋|手机版|Office中国/Access中国 ( 粤ICP备10043721号-1 )  

GMT+8, 2024-5-12 16:47 , Processed in 0.072866 second(s), 24 queries .

Powered by Discuz! X3.3

© 2001-2017 Comsenz Inc.

快速回复 返回顶部 返回列表