Click here to Skip to main content
15,885,873 members
Please Sign up or sign in to vote.
2.00/5 (1 vote)
See more:
hello all

I'm trying to change the time
today from the evening to the next morning
when time is adjusted to 12:00:00 AM dates automatically increase
when I step back 11:30:00: PM is automatically reduced the number of days
particularly when there is increased 12:30:00 AM and return 12:00:00 AM
the numbers continue to rise day

VB
Public Class Form2
    Public Sub New()

        ' This call is required by the Windows Form Designer.
        InitializeComponent()
        Me.Size = New Size(408, 328)
        Dim DateTimePicker1 As New DateTimePicker()
        DateTimePicker1.Location = New Point(10, 30)
        DateTimePicker1.Size = New Size(140, 32)

        Dim DateTimePicker2 As New DateTimePicker()
        DateTimePicker2.Location = New Point(190, 30)
        DateTimePicker2.Size = New Size(100, 32)
        DateTimePicker2.Format = DateTimePickerFormat.Time
        DateTimePicker2.ShowUpDown = True
        AddHandler DateTimePicker2.ValueChanged, AddressOf DateTimePicker2_ValueChanged

        Me.Controls.Add(DateTimePicker1)
        Me.Controls.Add(DateTimePicker2)

        ' Add any initialization after the InitializeComponent() call.

    End Sub
  
    Private Sub Form2_Load(ByVal sender As System.Object, ByVal e As System.EventArgs) Handles MyBase.Load

    End Sub

    Private Sub DateTimePicker2_ValueChanged(ByVal sender As System.Object, ByVal e As System.EventArgs)
        '?
    End Sub
End Class

http://s28.postimg.org/s7ofw82gd/change_value_datetimepicker.png[^]

any code that is appreciated
please get help
thanks a lot
Posted
Updated 27-Sep-14 9:04am
v2
Comments
Sergey Alexandrovich Kryukov 27-Sep-14 10:27am    
Why?
What have you tried so far?
I don't mean DateTimePicker use, which is majorly irrelevant.
—SA

1 solution

The question has nothing to do with DateTimePicker which is only used to pick some time. Generally, it's a bad idea to arbitrary set date/time on the system. You cannot provide reasonable accuracy, and so on. (I can be used to cheat copy protection systems, but newer protection is immune to such tricks. :-))

The solution can be found here: How to set global DateTime in .net[^].

Note that you have to use P/Invoke which compromises the platform compatibility of your code.

—SA
 
Share this answer
 
v2

This content, along with any associated source code and files, is licensed under The Code Project Open License (CPOL)



CodeProject, 20 Bay Street, 11th Floor Toronto, Ontario, Canada M5J 2N8 +1 (416) 849-8900