I have a checkbox in a userform that I check to update the time whenever daylight savings time is in effect. Is it possible for this checkbox to automatically get checked when daylight savings time on the computer is in effect?
I have a checkbox in a userform that I check to update the time whenever daylight savings time is in effect. Is it possible for this checkbox to automatically get checked when daylight savings time on the computer is in effect?
[vba]
Private Declare Function GetTimeZoneInformation Lib "kernel32" ( _
lpTimeZoneInformation As TIME_ZONE_INFORMATION) 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
Public Enum TIME_TYPE
INDETERMINATE_TIME = 0 ' Cannot determine DST
STANDARD_TIME = 1 ' Standard Time, not Daylight
DAYLIGHT_SAVINGS_TIME = 2 ' Daylight Time, not Standard
End Enum
Private Type TIME_ZONE_INFORMATION
Bias As Long
StandardName(0 To 31) As Integer
StandardDate As SYSTEMTIME
StandardBias As Long
DaylightName(0 To 31) As Integer
DaylightDate As SYSTEMTIME
DaylightBias As Long
End Type
Function DaylightMode() As TIME_TYPE
Dim TZI As TIME_ZONE_INFORMATION
Dim DST As TIME_TYPE
DST = GetTimeZoneInformation(TZI)
DaylightMode = DST
End Function
Sub TestDST()
MsgBox DaylightMode = DAYLIGHT_SAVINGS_TIME
End Sub
[/vba]
____________________________________________
Nihil simul inventum est et perfectum
Abusus non tollit usum
Last night I dreamed of a small consolation enjoyed only by the blind: Nobody knows the trouble I've not seen!
James Thurber
sorry for the late reply. Thank you XLD. The code works great.