Format 基本應用
Format(Time, "Long Time")
功能:以系統設定的長時間格式傳回現在系統時間。
結果:下午 03:16:46
'Time 為現在時間
Format(Date, "Long Date")
功能:以系統設定的長日期格式傳回現在系統日期。
結果:2016年6月18日
'Date 為現在日期
VB 的 Y 表示年、M表示月、D表示日或星期 (大小寫沒差)
設現在時間為 2016年6月9日 星期三 下午 09點23分04秒
年月日的用法如下:
yy | 16 |
yyyy | 2016 |
m | 6 |
mm | 06 |
mmm | Jun |
mmmm | June |
d | 9 |
dd | 09 |
ddd | Thu |
dddd | Thursday |
ddddd | 2016/6/9 |
可自行搭配看看
範例:
Format(Date, "yyyymmdd") '20160618
Format(Date, "yyyy-MM-dd,dddd") '2016-06-18,Saturday
Format(Date, "ddd, yyyy/MM/dd") 'Sat, 2016/06/18
Format("09:23:04", "h:m:s") '9:23:4
Format("09:23:04", "hh:mm:ss") '09:23:04
Format("09:23:04", "hh:mm:ss AMPM") '09:23:04 上午
' 使用者自訂的格式。
Format(5459.4, "##,##0,00") ' "5,459.40
Format(334。9, "###0,00") ' 334.90
Format(5, "0,00%") ' 500.00%"。
Format("HELLO", "<") ' hello (轉大寫)
Format("This is it", ">") ' THIS IS IT (轉小寫)
Format(123,"0000.00") '0123.00 (數字補0)
Format(123,"0000") '0123
Format(0, "Yes/No") 'No
Format(1, "True/False") 'True
Format(1, "On/Off") 'On
有任何問題歡迎留言問我…
留言列表