How to assign a Null value?

Heavenly

Well-known member
Joined
Aug 22, 2005
Messages
53
Location
Puerto Rico
Programming Experience
1-3
How to assign a Null value?

Public m_TimePressWasStart As DateTime = Now.ToLocalTime


This code won’t work:
m_TimePressWasStop = System.DBNull.Value.ToString

Neither this:
m_TimePressWasStop = CDate(System.DBNull.Value)
 
JuggaloBrotha:

Thanks

see this:
 

Attachments

  • untitled.JPG
    untitled.JPG
    25.1 KB · Views: 56
hmmm, i didnt know that, i've never had a need to clear a datetime variable

i couldnt find anything in the help search in the IDE either so i'm not sure it's possible :(
 
Thanks to JuggaloBrotha and to kulrom:

m_TimePressWasStart = Nothing
I tried that one too, but VB would not let me.

Spebby explanation
“DateTime is a value type (a structure) and can not be set to null or nothing as with all .Net value types. The default value for a datetime value is zeros for the date portion and 12:00:00 AM for the Time portion.”

This is what I’m trying to accomplish:

The database has two DateTime fields and only one OR the other is supposed to be filled with a Time (I don't need the date part of it, just the time) this is why I must be able to leave one of the fields uninitialized or null ot DBnull.
 
Havinf said that, I did test this solution
Public m_TimePressWasStop As Nullable(Of DateTime) = Nothing
over and over and it works just perfect.

thanks all
 
Back
Top