Reputation: 11
this is my code -
Dim provider As CultureInfo = CultureInfo.InvariantCulture
Dim a1 As DateTime = Nothing
insexp = DateTime.ParseExact(date1.SelectedValue, "MMMM yyyy", provider)
If a1.Month = Today.Month AndAlso a1.Year = Today.Year Then
a1 = Today.Date
End If
this will work only if date1.selectedvalue is not null, but will crash if it is null. how do i give if condition to run this only if not null? thanks
Upvotes: 1
Views: 990
Reputation: 829
Dim provider As CultureInfo = CultureInfo.InvariantCulture
Dim a1 As DateTime = Nothing
If not String.IsNullOrEmpty(date1.SelectedValue) Then
insexp = DateTime.ParseExact(date1.SelectedValue, "MMMM yyyy", provider)
End If
If a1.Month = Today.Month AndAlso a1.Year = Today.Year Then
a1 = Today.Date
End If
Upvotes: 1