当前位置: 网学 > 编程文档 > VB > 正文

VB关于日期的中文转换

来源:Http://myeducs.cn 联系QQ:点击这里给我发消息 作者: 用户投稿 来源: 网络 发布时间: 12/10/16
下载{$ArticleTitle}原创论文样式
 

下面的代码可以将任意日期(1000-01-01------>9999-12-31)转换为汉字显示:

 

Private Sub Command1_Click()
MsgBox datename(Date)
End Sub
Function datename(ByVal mydate As Date) As String
Dim i As Long, d(3) As String, myyear As String
myyear = Format(mydate, "yyyy")
For i = 1 To 4
d(0) = d(0) & Mid("○一二三四五六七八九", CInt(Mid(myyear, i, 1)) + 1, 1)'' trans year to chinese character
Next
d(1) = "年" & MonthName(Month(mydate)) ''add month name in chinese as “十月”
d(2) = Choose(Day(mydate) \ 10 + 1, "", "十", "二十", "三十") & Mid("  一二三四五六七八九", Day(mydate) Mod 10 + 1, 1) & "日"
d(3) = "," & WeekdayName(Weekday(mydate))''add weekday name in chinese as “星期三”
datename = Join(d, "") '' combine year,month and day,weekday
datename = Replace(datename, " ", "") '' avoid space in result
End Function

  • 上一篇资讯: VB 10个小编程技巧
  • 网学推荐

    免费论文

    原创论文

    浏览:
    设为首页 | 加入收藏 | 论文首页 | 论文专题 | 设计下载 | 网学软件 | 论文模板 | 论文资源 | 程序设计 | 关于网学 | 站内搜索 | 网学留言 | 友情链接 | 资料中心
    版权所有 QQ:3710167 邮箱:3710167@qq.com 网学网 [Myeducs.cn] 您电脑的分辨率是 像素
    Copyright 2008-2015 myeducs.Cn www.myeducs.Cn All Rights Reserved
    湘ICP备09003080号