Date Types in VB.NET Classes

Posted on 2009-07-15
Last Modified: 2012-06-27
I have a class in VB.NET 2008.  I have date types that are not always assigned a value. Nulls from the database.  However, when I load the data into my class VB assigns a default date.  Is this default assignment avoidable?  
Question by:dbote
Welcome to Experts Exchange

Add your voice to the tech community where 5M+ people just like you are talking about what matters.

  • Help others & share knowledge
  • Earn cash & points
  • Learn & ask questions

Accepted Solution

bhmahler earned 500 total points
ID: 24858974
You can try making the datatype a Nullable value

Public Property SomeDate As Nullable(Of Date)
    End Get
    Set(ByVal value As Nullable(Of Date))
    End Set
End Property

Open in new window


Author Closing Comment

ID: 31603713
This definitely works.  Thank you.
LVL 63

Expert Comment

by:Fernando Soto
ID: 24859137
Hi dbote;

Seeming you are using VS 2008 you can try making the Date data type a Nullable type as follows:

The following three statements are equivalent:

Dim dt? As DateTime
Dim dt As DateTime?
Dim dt As Nullable(Of DateTime)



Featured Post

PeopleSoft Has Never Been Easier

PeopleSoft Adoption Made Smooth & Simple!

On-The-Job Training Is made Intuitive & Easy With WalkMe's On-Screen Guidance Tool.  Claim Your Free WalkMe Account Now

Question has a verified solution.

If you are experiencing a similar issue, please ask a related question

Article by: jpaulino
XML Literals are a great way to handle XML files and the community doesn’t use it as much as it should.  An XML Literal is like a String ( Literal, only instead of starting and ending with w…
It was really hard time for me to get the understanding of Delegates in C#. I went through many websites and articles but I found them very clumsy. After going through those sites, I noted down the points in a easy way so here I am sharing that unde…
In this video, viewers will be given step by step instructions on adjusting mouse, pointer and cursor visibility in Microsoft Windows 10. The video seeks to educate those who are struggling with the new Windows 10 Graphical User Interface. Change Cu…
Michael from AdRem Software explains how to view the most utilized and worst performing nodes in your network, by accessing the Top Charts view in NetCrunch network monitor ( Top Charts is a view in which you can set seve…

631 members asked questions and received personalized solutions in the past 7 days.

Join the community of 500,000 technology professionals and ask your questions.

Join & Ask a Question