I am using infragistics controls here . How to validate and check if datatime value of current is greater than previous datatime values.
In the loop i have list of Dim datePicker As UltraDateTimeEditor = o
so i need to check for every loop if the current datepicker value is greater than previous one
Point to remember ...some of the datapicker values may be Nothing. So we should not compare with those.
For Each o As Object In UltraPanel1.ClientArea.Controls
If TypeOf (o) Is UltraDateTimeEditor Then
Dim datePicker As UltraDateTimeEditor = o
Dim datevalue As Object = datePicker.Value
End If
Next
You need to use a variable which is defined outside the loop so that you can hold the previous value in that variable and compare the current value with the previous one. and at the end of each iteration previous value should be updated with the current value since it will be the previous for the next iteration; The following code will help you:
Dim prevDatevalue As Object = Nothing
For Each o As Object In UltraPanel1.ClientArea.Controls
If TypeOf (o) Is UltraDateTimeEditor Then
Dim datePicker As UltraDateTimeEditor = o
Dim datevalue As Object = datePicker.Value
If prevDatevalue <> Nothing Then
If prevDatevalue < datevalue Then
' Do something Previous value is Lesser
Else
' Do something else Previous value is greater
End If
End IF
prevDatevalue = datePicker.Value
End If
Next