Reputation: 33
I'm fairly new to VBA code, and I'm running into a compile error when I try to run this code in a class I created.
Private pWorkDate As Date
Public Property Set WorkDate(value As Date)
Set pWorkDate = value
End Property
Public Property Get WorkDate() As Date
Set WorkDate = pWorkDate
End Property
This is the error message that I'm getting:
Definitions of property procedures for the same property are inconsistent, or property procedure has an optional parameter, a ParamArray, or an invalid Set final parameter
Please forgive my ignorance, but I have been searching around and can't seem to find what I'm doing wrong.
Upvotes: 3
Views: 2788
Reputation: 175896
It dislikes your attempt to use set
which is for object references, which a variable of type Date
can never be (its a primitive type (like integer
) not an object type (like your class)).
Change to Let
& don't use Set
:
Public Property Let WorkDate(value As Date)
pWorkDate = value
End Property
Public Property Get WorkDate() As Date
WorkDate = pWorkDate
End Property
Upvotes: 5