Creating a Null Datetime Object
A "null" LCDatetime value is one whose text is "". There are three ways to obtain such a value, as listed.
- Use the expression New LCDatetime, with no constructor arguments, to return a null date/time value.
- Set the Text property of LCDatetime (which is writeable) to "".
- Use the Clear method.
The following sample code demonstrates these three methods.
Sub Click(Source As Button)
Dim dat1 As New LCDatetime
dat1.SetCurrent ' set a value just so we have something to erase
Dim dat2 As New LCDatetime(2003, 10, 17, 15, 30, 0)
Dim dat3 As New LCDatetime
On Error Goto oops
Print dat1.Text & {, } & dat2.Text & {, } & dat3.Text
dat1.Text = ""
dat2.Clear
' don't need to clear dat3 because it was always a null value
Print dat1.Text & {, } & dat2.Text & {, } & dat3.Text
End Sub
The output that would result from this code sample is shown as follows.
<03/19/2003 05:39:10.25 PM, 10/17/2003 03:30:00 PM, >
<, , >