时间显示形式的问题?的解决答案

zhykhld 2007-01-22 07:43:39
为什么有超过3贴的限制?让我无法回贴!

函数getDateStr修改如下,其它的两个函数不用动

function getDateStr(theDate as date) as string
dim tmp as integer
dim dText as string
dim xx as integer

for xx=1 to 4
dtext=dtext+getintstr1(mid(format(thedate,"yyyy"),xx,1))
next
dtext=dtext+"年"
tmp=format(thedate,"m")
dtext=dtext+getintstr2(tmp)+iif(tmp mod 10>0,getintstr1(tmp),"")+"月
tmp=format(thedate,"d")
dtext=dtext+getintstr2(tmp)+iif(tmp mod 10>0,getintstr1(tmp),"")+"日
getdatestr=dtext
end function
...全文
140 2 打赏 收藏 转发到动态 举报
写回复
用AI写文章
2 条回复
切换为时间正序
请发表友善的回复…
发表回复
hui_hui_2007 2007-01-22
  • 打赏
  • 举报
回复
up
zhykhld 2007-01-22
  • 打赏
  • 举报
回复
全部代码如下,已经经过测试

Function getDateStr(theDate As Date) As String
Dim tmp As Integer
Dim dText As String
Dim xx As Integer

For xx = 1 To 4
dText = dText + getIntStr1(Mid(Format(theDate, "yyyy"), xx, 1))
Next
dText = dText + "年"
tmp = Format(theDate, "m")
dText = dText + getIntStr2(tmp) + IIf(tmp Mod 10 > 0, getIntStr1(tmp), "") + "月"
tmp = Format(theDate, "d")
dText = dText + getIntStr2(tmp) + IIf(tmp Mod 10 > 0, getIntStr1(tmp), "") + "日"
getDateStr = dText
End Function

Function getIntStr1(theInt As Integer) As String
''此函数只能接受一位的数字
Select Case theInt Mod 10
Case 0
getIntStr1 = "零"
Case 1
getIntStr1 = "一"
Case 2
getIntStr1 = "二"
Case 3
getIntStr1 = "三"
Case 4
getIntStr1 = "四"
Case 5
getIntStr1 = "五"
Case 6
getIntStr1 = "六"
Case 7
getIntStr1 = "七"
Case 8
getIntStr1 = "八"
Case 9
getIntStr1 = "九"
End Select
End Function

Function getIntStr2(theInt As Integer) As String
If theInt >= 30 Then
getIntStr2 = "卅"
ElseIf theInt >= 20 Then
getIntStr2 = "廿"
ElseIf theInt >= 10 Then
getIntStr2 = "十"
End If
End Function

7,763

社区成员

发帖
与我相关
我的任务
社区描述
VB 基础类
社区管理员
  • VB基础类社区
加入社区
  • 近7日
  • 近30日
  • 至今
社区公告
暂无公告

试试用AI创作助手写篇文章吧