In VB6 we put date values obtained from databases into variants. We can then use statements like IsNull(.EndDate ) to check whether a date is set or not. When you put code like this through the vb.net conversion wizard it turns out very messy and you have to make lots of changes by hand. The basic principle is that dates like this have to be represented as Nullable(Of Date) in vb.net.
In order to make life simpler, I have introduced two simple procedures into the VB6 code:
[CODE=vb]Public Function DateSet(ByVal InputDate As Variant) As Boolean
DateSet = Not IsNull(InputDat e)
End Function
Public Function DateNotSet(ByVa l InputDate As Variant)
DateNotSet = IsNull(InputDat e)
End Function[/CODE]
and have changed the vb6 code to use these procedures throughout. This also improves readability.
In vb.net the corresponding procedures are:
[CODE=vbnet]Public Function DateSet(ByVal Value As Nullable(Of Date)) As Boolean
DateSet = Value.HasValue
End Function[/CODE]
and
[CODE=vbnet]Public Function DateNotSet(ByVa l Value As Nullable(Of Date)) As Boolean
DateNotSet = Not Value.HasValue
End Function[/CODE]
In order to make life simpler, I have introduced two simple procedures into the VB6 code:
[CODE=vb]Public Function DateSet(ByVal InputDate As Variant) As Boolean
DateSet = Not IsNull(InputDat e)
End Function
Public Function DateNotSet(ByVa l InputDate As Variant)
DateNotSet = IsNull(InputDat e)
End Function[/CODE]
and have changed the vb6 code to use these procedures throughout. This also improves readability.
In vb.net the corresponding procedures are:
[CODE=vbnet]Public Function DateSet(ByVal Value As Nullable(Of Date)) As Boolean
DateSet = Value.HasValue
End Function[/CODE]
and
[CODE=vbnet]Public Function DateNotSet(ByVa l Value As Nullable(Of Date)) As Boolean
DateNotSet = Not Value.HasValue
End Function[/CODE]
Comment