Last post Jan 12, 2011 06:56 PM by GMann
Jan 11, 2011 06:54 PM|GMann|LINK
Where do I validate my date values prior to passing them as insert parms ?
I am trying to pass some Null dates.
In my property ?
Public Property BirthDate As Date
Set(ByVal value As Date)
m_BirthDate = value
Jan 11, 2011 07:11 PM|AceCorban|LINK
Yeah, DateTime is a struct, so it doesn't allow null values. I usually use the static value "DateTime.MinValue" for my initialized values.
Or, if you really want to use null, you can look at this article:
I find it complicates things, because you have to keep using the coallesce operator (??).
Jan 12, 2011 06:56 PM|GMann|LINK
I found this code for VB in a book.
This is another way of passing null dates from a class property.
Step 1. define your classes' private var as type NUllable(of Date).
Step 2. make your property type Nullable(Of Date) too.
Public Property Birthdate As Nullable(Of Date)
If m_Birthdate.HasValue Then
Set(ByVal value As Nullable(Of Date))
m_Birthdate = value