不知道有没有其他好方法。 Declare Function SetSystemTime Lib "kernel32" Alias "SetSystemTime" (lpSystemTime As SYSTEMTIME) As Long ==================== Type SYSTEMTIME ' 16 Bytes 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 说明 This structure contains date and time information.
字段表 字段 类型与说明 wYear Integer,The current year. wMonth Integer,The current month. January is 1. wDayOfWeek Integer,The current day of the week. Sunday is 0. wDay Integer,The current day of the month. wHour Integer,The current hour. wMinute Integer,The current minute. wSecond Integer,The current second. wMilliseconds Integer,The current millisecond.
Option Explicit Private Declare Function SetSystemTime Lib "kernel32" (lpSystemTime As SYSTEMTIME) As LongPrivate Type SYSTEMTIME ' 16 Bytes 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 TypeDim a As SYSTEMTIMEPrivate Sub Form_Load() Dim d As Long a.wYear = 2004 a.wMonth = 11 a.wDayOfWeek = 0 a.wDay = 3 a.wHour = 15 a.wMinute = 25 a.wSecond = 34 a.wMilliseconds = 1 d = SetSystemTime(a) End Sub
Dim MyTime MyTime = #4:35:17 PM# ' 指定一时间。 Time = MyTime ' 将系统时间设置为 MyTime 的内容。
Declare Function SetSystemTime Lib "kernel32" Alias "SetSystemTime" (lpSystemTime As SYSTEMTIME) As Long
====================
Type SYSTEMTIME ' 16 Bytes
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
说明
This structure contains date and time information.
字段表
字段 类型与说明
wYear Integer,The current year.
wMonth Integer,The current month. January is 1.
wDayOfWeek Integer,The current day of the week. Sunday is 0.
wDay Integer,The current day of the month.
wHour Integer,The current hour.
wMinute Integer,The current minute.
wSecond Integer,The current second.
wMilliseconds Integer,The current millisecond.
Private Declare Function SetSystemTime Lib "kernel32" (lpSystemTime As SYSTEMTIME) As LongPrivate Type SYSTEMTIME ' 16 Bytes
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 TypeDim a As SYSTEMTIMEPrivate Sub Form_Load()
Dim d As Long
a.wYear = 2004
a.wMonth = 11
a.wDayOfWeek = 0
a.wDay = 3
a.wHour = 15
a.wMinute = 25
a.wSecond = 34
a.wMilliseconds = 1
d = SetSystemTime(a)
End Sub
MyTime = #4:35:17 PM# ' 指定一时间。
Time = MyTime ' 将系统时间设置为 MyTime 的内容。
time= CDate("2004-11-03 15:49:32")改为
date= CDate("2004-11-03 15:49:32")
now=CDate("2004-11-03 15:49:32")
好经典啊以前还用一大堆麻烦的API
Time = CDate("2004-11-03 15:49:32")
强啊