Results 1 to 2 of 2

Thread: Change the system Date/Time

  1. #1

    Thread Starter
    Hyperactive Member stingrae's Avatar
    Join Date
    Apr 2002
    Location
    Sydney
    Posts
    401

    Resolved Change the system Date/Time

    as per the title, does anyone know how to Change the System Date/Time via VB.Net?

    thanks in advance
    Last edited by stingrae; Apr 28th, 2011 at 07:45 PM. Reason: Resolved
    "The passion lives to keep your faith, though all are different, all are great" ... Michael Hutchence 1960-1997.

    Windows & Web Developer
    Specialising in Visual Basic .Net & Client Server Programming & Client/Customer Relations Databases
    Sutherland Shire, Sydney Australia
    www.stingrae.com.au
    Developer of Arnold - Gym & Martial Arts Database Management System
    www.gymdatabase.com.au

  2. #2

    Thread Starter
    Hyperactive Member stingrae's Avatar
    Join Date
    Apr 2002
    Location
    Sydney
    Posts
    401

    Re: Change the system Date/Time

    Found how to:

    (if this is not the best way, please add)

    Code:
        Private Structure SYSTEMTIME
    
            Public year As Short
    
            Public month As Short
    
            Public dayOfWeek As Short
    
            Public day As Short
    
            Public hour As Short
    
            Public minute As Short
    
            Public second As Short
    
            Public milliseconds As Short
    
        End Structure
    
        <DllImport("Kernel32.dll")> Private Shared Function SetLocalTime(ByRef time As SYSTEMTIME) As Boolean
    
        End Function
    
        Private Sub ChangeDate
    
                    Dim st As SYSTEMTIME
                    Dim NewDate As Date = "28-April-1978 22:30:00"
                    st.year = NewDate .Year
                    st.month = NewDate.Month
                    st.dayOfWeek = NewDate.DayOfWeek
                    st.day = NewDate.Day
                    st.hour = NewDate.Hour
                    st.minute = NewDate.Minute
                    st.second = NewDate.Second
                    st.milliseconds = NewDate.Millisecond
    
                    'Set the new time...
                    SetLocalTime(st)
        End Sub
    "The passion lives to keep your faith, though all are different, all are great" ... Michael Hutchence 1960-1997.

    Windows & Web Developer
    Specialising in Visual Basic .Net & Client Server Programming & Client/Customer Relations Databases
    Sutherland Shire, Sydney Australia
    www.stingrae.com.au
    Developer of Arnold - Gym & Martial Arts Database Management System
    www.gymdatabase.com.au

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