Contact US

Log In

Come Join Us!

Are you a
Computer / IT professional?
Join Tek-Tips Forums!
  • Talk With Other Members
  • Be Notified Of Responses
    To Your Posts
  • Keyword Search
  • One-Click Access To Your
    Favorite Forums
  • Automated Signatures
    On Your Posts
  • Best Of All, It's Free!

*Tek-Tips's functionality depends on members receiving e-mail. By joining you are opting in to receive e-mail.

Posting Guidelines

Promoting, selling, recruiting, coursework and thesis posting is forbidden.

Students Click Here

Visual Basic (Classic) FAQ

Quirks of Framework 2.0

Date/DateTime Type cannot be NEW()'ed with Date/DateTime instance by Qik3Coder
Posted: 23 Jan 07

Instead of:


Dim myDate As New Date(Now())
Dim myDateTime As New DateTime(Now())
You must write:


Dim myDate As New Date()
myDate = Now()
Dim myDateTime As New DateTime()
myDateTime = Now()


Dim myDate As Date = Now()
Dim myDateTime As DateTime = Now()

Keep in mind this example may seem a little irrelevant, but it's a quirk of the system, you cannot create a new Date/DateTime instance with an instance of Date/DateTime.

Now you will probably say, "Well there are 11 different New constructors for the Date/Datetime Types. There must be one that you can use."

The problem lies in that only one of the constructors takes a base type (of Long), and the Date/DateTime types do not have a .ToLong property. All the other Constructors take date parts.



Back to Visual Basic (Classic) FAQ Index
Back to Visual Basic (Classic) Forum

My Archive

Close Box

Join Tek-Tips® Today!

Join your peers on the Internet's largest technical computer professional community.
It's easy to join and it's free.

Here's Why Members Love Tek-Tips Forums:

Register now while it's still free!

Already a member? Close this window and log in.

Join Us             Close