VB 读取系统年月日
请问VB要调用什么API函数才能读取系统时间?不是XX时:XX分之类的,而是XX年/XX月/XX日,这种格式的。...
请问VB要调用什么API函数才能读取系统时间?不是XX时:XX分之类的,而是XX年/XX月/XX日,这种格式的。
展开
展开全部
不需要用api函数的,直接用
format(date,"yy年mm月rr日")的格式就可以得到系统日期,如果非要用api函数,可以使用GetSystemTime或GetLocalTime,前者得到标准时间,
Private Declare Sub GetSystemTime Lib "kernel32" (lpSystemTime As SYSTEMTIME)
Private Declare Sub GetLocalTime Lib "kernel32" (lpSystemTime As SYSTEMTIME)
Private Type SYSTEMTIME
wYear As Integer
wMonth As Integer
wDayOfWeek As Integer
wDay As Integer
wHour As Integer
wMinute As Integer
wSecond As Integer
wMilliseconds As Integer
End Type
Sub Macro1()
Dim sys As SYSTEMTIME
GetLocalTime sys
msgbox sys.year & "年" & sys.month & "月" & sys.day & "日"
format(date,"yy年mm月rr日")的格式就可以得到系统日期,如果非要用api函数,可以使用GetSystemTime或GetLocalTime,前者得到标准时间,
Private Declare Sub GetSystemTime Lib "kernel32" (lpSystemTime As SYSTEMTIME)
Private Declare Sub GetLocalTime Lib "kernel32" (lpSystemTime As SYSTEMTIME)
Private Type SYSTEMTIME
wYear As Integer
wMonth As Integer
wDayOfWeek As Integer
wDay As Integer
wHour As Integer
wMinute As Integer
wSecond As Integer
wMilliseconds As Integer
End Type
Sub Macro1()
Dim sys As SYSTEMTIME
GetLocalTime sys
msgbox sys.year & "年" & sys.month & "月" & sys.day & "日"
展开全部
Dim str1 As String
str1=Format(date,"yy年mm月dd日")
str1=Format(date,"yy年mm月dd日")
本回答被提问者采纳
已赞过
已踩过<
评论
收起
你对这个回答的评价是?
展开全部
Format(Now(), "yyyy-mm-dd")
已赞过
已踩过<
评论
收起
你对这个回答的评价是?
推荐律师服务:
若未解决您的问题,请您详细描述您的问题,通过百度律临进行免费专业咨询