Your code will have statements like if (DOBGiven) rather than if (DOB == Date Time. Hi anders, It is true that you can't get an invalid date with the nullable type, you would just get an exception if you used . Either way, it is a bug which should be caught by you TDD methods. You code may be more complex but it should be easier to understand. Have a nice day a Date; a Date = Get From Database(); // if you get Date then it must be in a Date. Vaue will be null; ----- a Date = null; a Date = Date Time. If using nullable types you get the same advantage, but without the risk of using an invalid date. Because the compiler won't let me use a Date Time unless it has been initialised I would probably end up with a screen that shows a DOB as 1/1/1 and using the nullable type I would have an exception and no screen at all, take your pick. To me, the Has Value property is a detail of the CLR (or is it the language? It's a case of the low-level technical details versus the business case that is being addressed.In some instances, you have no choice about your Data Types.
ADezii, It seems Lady Reader may already have her solution. Declaring Export Start Date and Export End Date as Variants may or may not be more elegant for Lady Reader, but won't it cut down on her code's efficiency? The Variant Data Type is convenient, but it is not always the best choice.
It's tempting to Declare all your Variables as Variants so you don't have to worry about what is in them but if you think that something will always be an Integer, Declare it as such.
How do you deal with a Date Time that should be able to contain an uninitialized value (equivalent to null)? So - now the issue comes to mind as to the best way to access the Date Time object.
I have a class which might have a Date Time property value set or not. There are a few ways, number 1 is by FAR the best and 2 is "dude why".
When the user wants to export data to Excel I allow them to specify the date range, but they can also Cancel the action.