回 帖 发 新 帖 刷新版面

主题:[转帖]Format函数应用

前几天正被这个问题所困饶,好不容易找到解决的方法,发上来跟大家分享分享,我想回有不少人跟我一样遇到同样的问题的。

本例显示同时使用 String 格式和用户定义格式格式化值的 Format 函数的各种用法。对于日期分隔符 (/)、时间分隔符 (:) 和 AM/PM 指示符(t 和 tt),系统显示的实际格式化输出取决于代码使用的区域设置。当在开发环境中显示时间和日期时,使用代码区域设置的短时间格式和短日期格式。 
Dim MyDateTime As Date = #1/27/2001 5:04:23 PM# 
Dim MyStr As String 
’ Returns current system time in the system-defined long time format. 
MyStr = Format(Now(), "Long Time") 
’ Returns current system date in the system-defined long date format. 
MyStr = Format(Now(), "Long Date") 
’ Also returns current system date in the system-defined long date  
’ format, using the single letter code for the format. 
MyStr = Format(Now(), "D") 
’ Returns the value of MyDateTime in user-defined date/time formats. 
MyStr = Format(MyDateTime, "h:m:s") ’ Returns "5:4:23". 
MyStr = Format(MyDateTime, "hh:mm:ss tt") ’ Returns "05:04:23 PM". 
MyStr = Format(MyDateTime, "dddd, MMM d yyyy") ’ Returns "Saturday, 
’ Jan 27 2001". 
MyStr = Format(MyDateTime, "HH:mm:ss") ’ Returns "17:04:23" 
MyStr = Format(23) ’ Returns "23". 
’ User-defined numeric formats. 
MyStr = Format(5459.4, "##,##0.00") ’ Returns "5,459.40". 
MyStr = Format(334.9, "###0.00") ’ Returns "334.90". 
MyStr = Format(5, "0.00%") ’ Returns "500.00%". 
该文章转载自[编程助理站]:http://www.91duoduo.com/jishu/net_xx.asp?noid=hfhdik3yhj8jntm

回复列表 (共13个回复)

沙发

没人顶,自己顶

板凳

ding

3 楼

d

4 楼

d

5 楼

dddddddddddddd

6 楼

dddddddddddd

7 楼

ddddddddd

8 楼

ddddddddd

9 楼

ddddddddddddddddddddd

10 楼

赌东道赌东道赌东道的

我来回复

您尚未登录,请登录后再回复。点此登录或注册