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
Unfortunately, activation email could not send to your email. Please try again.
Syncfusion Feedback

System Date

Thread ID:





689 Jul 30,2002 07:55 AM UTC Jul 30,2002 10:40 AM UTC WinForms 1
Tags: FAQ
Vipul Bhatt
Asked On July 30, 2002 07:55 AM UTC

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

Clay Burch [Syncfusion]
Replied On July 30, 2002 10:40 AM UTC

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
    End Sub


This post will be permanently deleted. Are you sure you want to continue?

Sorry, An error occured while processing your request. Please try again later.

Please sign in to access our forum

This page will automatically be redirected to the sign-in page in 10 seconds.

Warning Icon You are using an outdated version of Internet Explorer that may not display all features of this and other websites. Upgrade to Internet Explorer 8 or newer for a better experience.Close Icon

Live Chat Icon For mobile
Live Chat Icon