• Status: Solved
  • Priority: Medium
  • Security: Public
  • Views: 155
  • Last Modified:

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?
0
derekl
Asked:
derekl
1 Solution
 
AzraSoundCommented:
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
Concerto's Cloud Advisory Services

Want to avoid the missteps to gaining all the benefits of the cloud? Learn more about the different assessment options from our Cloud Advisory team.

 
É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

Featured Post

Important Lessons on Recovering from Petya

In their most recent webinar, Skyport Systems explores ways to isolate and protect critical databases to keep the core of your company safe from harm.

Tackle projects and never again get stuck behind a technical roadblock.
Join Now