Go Back  Xtreme Visual Basic Talk > Legacy Visual Basic (VB 4/5/6) > General > Date & Time


Reply
 
Thread Tools Display Modes
  #1  
Old 08-04-2002, 08:10 AM
vbtester vbtester is offline
Junior Contributor
 
Join Date: May 2002
Posts: 211
Default Date & Time


Hello all,

I am wondering if anyone knows of a way to get the System Date and Time. Not Windows Date & Time. If I use the Now() or Date() function, that will only return me the Windows Time.

I need to get the correct time from the BIOS. I noticed when I added a Date Picker Control to one of my VB projects, no matter what changes I made to the Windows Clock, the Date Picker Control always had the correct date in it.

Where is that date comming from? The reason I need to do this is I need to dectect a new Day in my App. But if someone changes the Windows Clock, then my App does not work properly. How can I get the proper Date from the System?

Thanks in advance.
Reply With Quote
  #2  
Old 08-04-2002, 09:11 AM
Ales Zigon's Avatar
Ales Zigon Ales Zigon is offline
Dead dog's ghost

Forum Leader
* Expert *
 
Join Date: Feb 2001
Location: Celje, Slovenia, Europe
Posts: 2,601
Default

Use GetSystemTime API.

From API guide:
Code:
Private Declare Sub GetSystemTime 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/
    'KPDTeam@Allapi.net
    Dim SysTime As SYSTEMTIME
    'Set the graphical mode to persistent
    Me.AutoRedraw = True
    'Get the system time
    GetSystemTime SysTime
    'Print it to the form
    Me.Print "The System Date is:" & SysTime.wMonth & "-" & SysTime.wDay & "-" & SysTime.wYear
    Me.Print "The System Time is:" & SysTime.wHour & ":" & SysTime.wMinute & ":" & SysTime.wSecond
End Sub
__________________
Yes, MSDN comes with VB! Yes, you must have at least 25 post to have an avatar! No, you cant write your OS in VB! and NO, YOU CAN NOT DECOMPILE IT!

I'm sure there are things that are more important than me - I just can't thing of any...
Reply With Quote
  #3  
Old 08-05-2002, 08:15 AM
vbtester vbtester is offline
Junior Contributor
 
Join Date: May 2002
Posts: 211
Default

Thank-you for your post, unfortunatly this does not work.

If you change the time on the windows clock, then this code your provided shows the in-correct date.

I was wondering if there is a way to get the Proper date, even if the user changes the windows clock.

Any help is appreciated.

Thanks
Reply With Quote
Reply


Currently Active Users Viewing This Thread: 1 (0 members and 1 guests)
 
Thread Tools
Display Modes

Posting Rules
You may not post new threads
You may not post replies
You may not post attachments
You may not edit your posts

BB code is On
Smilies are On
[IMG] code is Off
HTML code is Off

Forum Jump

Advertisement:





Free Publications
The ASP.NET 2.0 Anthology
101 Essential Tips, Tricks & Hacks - Free 156 Page Preview. Learn the most practical features and best approaches for ASP.NET.
subscribe
Programmers Heaven C# School Book -Free 338 Page eBook
The Programmers Heaven C# School book covers the .NET framework and the C# language.
subscribe
Build Your Own ASP.NET 3.5 Web Site Using C# & VB, 3rd Edition - Free 219 Page Preview!
This comprehensive step-by-step guide will help get your database-driven ASP.NET web site up and running in no time..
subscribe
 
 
-->