CodeItBetter Programming Another VB Programming Blog

How to set System Date & time (in two ways)

Posted on January 4, 2009
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
'System & API - How to set System Date & time (in two ways)
'Method 1:

Sub OpenDateTimePropertiesDialog()
    time = #10:25:30 PM#    ' Set System Time
    Date = #1/1/1999#    ' Set System Date
End Sub
 
'Method 2 (Using API):

Private Declare Function SetSystemTime Lib "kernel32" (lpSystemTime As SYSTEMTIME) As Long
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 Main()
    Dim strucTime As SYSTEMTIME
    strucTime.wDay = Day(Date) + 2
    strucTime.wHour = Hour(Time) + 2
    strucTime.wMinute = Minute(Time)
    Call SetSystemTime(strucTime)
End Sub
Comments (0) Trackbacks (0)

No comments yet.


Leave a comment


 

No trackbacks yet.