L
lbsaltzman
Guest
Here is a problem I ran into in vb .net in relation to some validation called from a value changed event. On a Windows form I have a NumericUpDown control and a Date time Picker control. The Date time picker is used to select the beginning date of an agreement and the NumericUpDown control to set the number of days the control is in force. I have code to recalculate the end date based on the values of these to fields. I want to call that code from value_changed and leave events of these two controls. The code works with the leave event and crashes badly with the value_changed event. The code also works with a variety of keypress and mouse events as well.
Here is the code for the problem. I left out the Try, Catch end try in this sample, but wheither that is present or not I am getting a stackoverflow error message and the error triggers when the form is loading. As I said this same validation works perfectly placed in almost any event.
Private Sub dtpStartDate_ValueChanged(ByVal sender As System.Object, ByVal e As System.EventArgs) Handles dtpStartDate.ValueChanged
Call ChangeAgrmntEndDate()
End Sub
Private Sub ChangeAgrmntEndDate()
Dim DateReturn As Date
Dim StartDate As Date
Dim dblAgrmntLngth As Double
Dim strDateReturn As String
StartDate = Me.dtpStartDate.Value
dblAgrmntLngth = Me.updAgrmntLngth.Value
DateReturn = CalculateAgrmntDate(StartDate, dblAgrmntLngth)
strDateReturn = CStr(DateReturn)
Me.txtEndDate.Text = strDateReturn
End Sub
If anyone has had any experience yet with the vagaries errors during events that can explain this I will greatly appreciate some help.
Here is the code for the problem. I left out the Try, Catch end try in this sample, but wheither that is present or not I am getting a stackoverflow error message and the error triggers when the form is loading. As I said this same validation works perfectly placed in almost any event.
Private Sub dtpStartDate_ValueChanged(ByVal sender As System.Object, ByVal e As System.EventArgs) Handles dtpStartDate.ValueChanged
Call ChangeAgrmntEndDate()
End Sub
Private Sub ChangeAgrmntEndDate()
Dim DateReturn As Date
Dim StartDate As Date
Dim dblAgrmntLngth As Double
Dim strDateReturn As String
StartDate = Me.dtpStartDate.Value
dblAgrmntLngth = Me.updAgrmntLngth.Value
DateReturn = CalculateAgrmntDate(StartDate, dblAgrmntLngth)
strDateReturn = CStr(DateReturn)
Me.txtEndDate.Text = strDateReturn
End Sub
If anyone has had any experience yet with the vagaries errors during events that can explain this I will greatly appreciate some help.