datetimepicker control looping

hubbard92

Member
Joined
Dec 12, 2006
Messages
11
Programming Experience
Beginner
Hi,

I have a datetimepicker control on my form and when I run the app and select the drop down arrow to pick a date on the datetimepicker control and then try and select a different month, the app starts repeating the
DateTimePicker1_ValueChanged event over and over each time incrementing the month by one each time.

I have tried to run this with the msgbox and without the msgbox and it runs fine without the msgbox, but when adding the msgbox it starts looping when trying to change the month.

Can someone please tell me why this is happening? My code is listed below

Private
Sub DateTimePicker1_ValueChanged(ByVal sender As System.Object, ByVal e As System.EventArgs) Handles DateTimePicker1.ValueChanged
Dim ws_area As String
ws_area = DateTimePicker1.Value
MsgBox("Is the following date correct " & ws_area)
End Sub
 
This is a known problem with the messagebox in that event, so you can't use messagebox in that event.
 
I am having the exact same problem!
When I run my application on an XP machine it loops... but when I use Vista it doesn't...

I really need a messagebox when an invalid date is selected... any tricks??
 
There is, I just had the idea to run the messagebox in a new thread and it worked:
VB.NET:
    Private Sub DateTimePicker1_ValueChanged(ByVal sender As System.Object, ByVal e As System.EventArgs) _
    Handles DateTimePicker1.ValueChanged
        Dim t As New Threading.Thread(AddressOf msgthread)
        t.Start()
    End Sub
 
    Private Sub msgthread()
        MsgBox(DateTimePicker1.Value.ToString)
    End Sub
 
Back
Top