views:

100

answers:

1

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

+4  A: 
If date1.SelectedValue IsNot Nothing Then
    ...
End If
tster