Results 1 to 4 of 4

Thread: How do I use GetLocalTime?

  1. #1
    tdm116
    Guest

    Question How do I use GetLocalTime?

    I wrote a VB6 app that uses date parts--DatePart("h", Now), but this part of the program does not appear to work on machines running Windows 95.

    I was told to use an API call and was given this text:

    Public 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

    Dim ST as SYSTEMTIME

    GetLocalTime ST

    How do I use this info? Does it all go in a module? Is anything missing? Is there a better way to get current date and time parts that is supported by Windows 95?

    Thanks!

  2. #2
    I'm about to be a PowerPoster! Hack's Avatar
    Join Date
    Aug 2001
    Location
    Searching for mendhak
    Posts
    58,333
    How about something easy like
    VB Code:
    1. Msgbox Now

  3. #3
    jim mcnamara
    Guest
    Code:
    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
    Private Sub Form_Load()
        'KPD-Team 1998
        'URL: http://www.allapi.net/
        'E-Mail: [email protected]
        Dim MyTime As SYSTEMTIME
        'Set the graphical mode to persistent
        Me.AutoRedraw = True
        'Get the local time
        GetLocalTime MyTime
        'Print it to the form
        Me.Print "The Local Date is:" & MyTime.wMonth & "-" & MyTime.wDay & "-" & MyTime.wYear
        Me.Print "The Local Time is:" & MyTime.wHour & ":" & MyTime.wMinute & ":" & MyTime.wSecond
    End Sub

  4. #4
    tdm116
    Guest
    Thank you, Jim.

Posting Permissions

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



Click Here to Expand Forum to Full Width