Consulting

Results 1 to 3 of 3

Thread: Daylight savings time

  1. #1

    Daylight savings time

    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?

  2. #2
    Distinguished Lord of VBAX VBAX Grand Master Bob Phillips's Avatar
    Joined
    Apr 2005
    Posts
    25,453
    Location
    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
    ____________________________________________
    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

  3. #3
    sorry for the late reply. Thank you XLD. The code works great.

Tags for this Thread

Posting Permissions

  • You may not post new threads
  • You may not post replies
  • You may not post attachments
  • You may not edit your posts
  •