We use cookies to give you the best experience on our website. If you continue to browse, then you agree to our privacy policy and cookie policy. Image for the cookie policy date

System Date

Hi Clay. Ca U pls tell how can i change system date in VB.NET THANK YOU in advance.

1 Reply

CB Clay Burch Syncfusion Team July 30, 2002 06:40 AM

There's no framework method that will handle this. You can use P/Invoke to call a Win32 API to set the system date/time. In your form level code, add
Private Structure SYSTEMTIME
        Public wYear As Short
        Public wMonth As Short
        Public wDayOfWeek As Short
        Public wDay As Short
        Public wHour As Short
        Public wMinute As Short
        Public wSecond As Short
        Public wMilliseconds As Short
    End Structure

    Private Declare Function SetSystemTime Lib "kernel32" (ByRef lpSystemTime As SYSTEMTIME) As Boolean
Then in a method, use code such as this to set the date.
   Private Sub Button1_Click(ByVal sender As System.Object, ByVal e As System.EventArgs) Handles Button1.Click

        Dim lpSystemTime As SYSTEMTIME
        lpSystemTime.wDay = 12
        lpSystemTime.wMonth = 7
        lpSystemTime.wYear = 2002

        ' Fill the structure and call
        SetSystemTime(lpSystemTime)
    End Sub

Loader.
Live Chat Icon For mobile
Up arrow icon