[VB6] Need Time Code

Discussion in 'Code Snippets and Tutorials' started by Anonymous, Mar 5, 2007.

  1. Anonymous

    Anonymous Guest

    Does anyone have a code I could use in my log? eg.

    [10:13:57] Refreshed... No random events
    [10:13:59] Refreshed... No random enevnt

    Thanks,
    Oddworth
     
  2. the_skip

    the_skip Level IV

    Joined:
    Dec 25, 2006
    Messages:
    2,354
    Likes Received:
    1
    Location:
    Indiana
    lstresults.additem "Random Event At" & Time & ""
     
  3. Anonymous

    Anonymous Guest

    is't a pre-defined function? thanks.
     
  4. the_skip

    the_skip Level IV

    Joined:
    Dec 25, 2006
    Messages:
    2,354
    Likes Received:
    1
    Location:
    Indiana
    Code (Text):
    1. Private Type SYSTEMTIME
    2.     wYear As Integer
    3.     wMonth As Integer
    4.     wDayOfWeek As Integer
    5.     wDay As Integer
    6.     wHour As Integer
    7.     wMinute As Integer
    8.     wSecond As Integer
    9.     wMilliseconds As Integer
    10. End Type
    11.  
    12. Private Declare Sub GetSystemTime Lib "kernel32" (lpSystemTime As SYSTEMTIME)
    13.  
    14. Private Sub Form_Load()
    15.     Dim SysTime As SYSTEMTIME
    16.    
    17.     'Set the graphical mode to persistent
    18.     Me.AutoRedraw = True
    19.    
    20.     'Get the system time
    21.     GetSystemTime SysTime
    22.    
    23.     'Print it to the form
    24.     Me.Print "The System Date is:" & _
    25.         SysTime.wMonth & "-" & SysTime.wDay & "-" & SysTime.wYear
    26.        
    27.     Me.Print "The System Time is:" & _
    28.         SysTime.wHour & ":" & SysTime.wMinute & ":" & SysTime.wSecond
    29. End Sub
    30.  
    31.  
    that is what I found
     
  5. ricky92

    ricky92 Administrator
    Staff Member

    Joined:
    Nov 10, 2006
    Messages:
    1,866
    Likes Received:
    67
    Well, the code to get the current time is "Time", nothing else. For my log I use this code:
    Code (Text):
    1. Log.AddItem "<" & Time & "> Start!"
    Really simple ;)
     
  6. Anonymous

    Anonymous Guest

    thanks. +rep!