Names of properties in custom classes

I'd like to define a property named Date in a class that I am writing.

But, when I input the following property definition
   
    Public Property Get Date() As Date
        ...
    End Property

I get:

    Compile Error
    Expected: identifier

I'm assuming that this has something to do with the built in Date object.  Is there any way to get around this?
dereklAsked:
Who is Participating?
 
AzraSoundConnect With a Mentor Commented:
Yes it is due to the intrinsic Date function.  You need to change the property name.  If it is a specific date, give it more meaning, e.g. LoginDate, DateSubmitted, InvoiceDate, etc.
0
 
rspahitzCommented:
You can try to suffix it with an underscore.  Not exactly what you want, but reasonably close.


Public Property Get Date_() As Variant

End Property

Public Property Let Date_(ByVal vNewValue As Variant)

End Property
0
 
Richie_SimonettiIT OperationsCommented:
Keywords cannot be used as name for variables, constants, properties like any other language (as long as i know).
0
Cloud Class® Course: CompTIA Cloud+

The CompTIA Cloud+ Basic training course will teach you about cloud concepts and models, data storage, networking, and network infrastructure.

 
Éric MoreauSenior .Net ConsultantCommented:
Try this:

Public Property Get [Date]() As Date
0
 
dereklAuthor Commented:
Public Property Get[Date]() As Date did not work.
0
 
Richie_SimonettiIT OperationsCommented:
what about Azra and rspahitz comments?
0
 
rspahitzCommented:
Personally, I think Azra's comment makes the most sense (in addition to answering the Q!) since the date will most likely not be "generic" but will be related to something.
0
 
Richie_SimonettiIT OperationsCommented:
Why "B" grade? what were you waiting for?
0
Question has a verified solution.

Are you are experiencing a similar issue? Get a personalized answer when you ask a related question.

Have a better answer? Share it in a comment.

All Courses

From novice to tech pro — start learning today.