Smart questions
Smart answers
Smart people
INTELLIGENT WORK FORUMS
FOR COMPUTER PROFESSIONALS

Member Login

Come Join Us!

Are you a
Computer / IT professional?
Join Tek-Tips now!
  • 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!

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

LINK TO THIS FORUM!

Add Stickiness To Your Site By Linking To This Professionally Managed Technical Forum.
Just copy and paste the
code below into your site.

Partner With Us!

"Best Of Breed" Forums Add Stickiness To Your Site
Partner Button
(Download This Button Today!)

Feedback

"...I have been a grateful member of this site for several years. I love this site and refer everyone to it!..."

Geography

Where in the world do Tek-Tips members come from?
ChewDoggie (Programmer)
30 Oct 08 0:17
I'm providing this as a quote from the VB Help pages titled "Putting Property Procedures to Work for You":

"Read-Write Properties
The following code fragment shows a typical read-write property:

' Private storage for property value.
Private mintNumberOfTeeth As Integer

Public Property Get NumberOfTeeth() As Integer
   NumberOfTeeth = mintNumberOfTeeth
End Property

Public Property Let NumberOfTeeth(ByVal NewValue _
   As Integer)
   ' (Code to validate property value omitted.)
   mintNumberOfTeeth = NewValue
End Property

The name of the private variable that stores the property value is made up of a scope prefix (m) that identifies it as a module-level variable; a type prefix (int); and a name (NumberOfTeeth). Using the same name as the property serves as a reminder that the variable and the property are related.

As you've no doubt noticed, here and in earlier examples, the names of the property procedures that make up a read-write property must be the same."

OK, so here's a snippet of my code in my class module:

CODE

Private mPromoterID As Integer

Public Property Let PromoterID(tpromoterid As Integer)
    mPromoterID = tpromoterid
End Property

Public Property Get PromoterID()
    PromoterID = mPromoterID
End Property

My property procedures have a common name, "PromoterID".  But when I go to execute the project, I receive the following "Compile Error" and highlights the "Let" procedure:

"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"

When I give the two procedures a unique name like below, it compiles and executes just fine.

CODE

Private mPromoterID As Integer

Public Property Let lPromoterID(tpromoterid As Integer)
    mPromoterID = tpromoterid
End Property

Public Property Get gPromoterID()
    gPromoterID = mPromoterID
End Property

Why can't I give these two procedures a common name?  I see examples ALL THE TIME where Get and Let procedures have common names.  Why can't mine be so ?

Thanks!

Chew

10% of your life is what happens to you.  90% of your life is how you deal with it.

strongm (MIS)
30 Oct 08 3:32
Change

Public Property Get PromoterID()

to

Public Property Get PromoterID() As Integer

With your version the Get is returning a Variant, whilst the Let is expecting an Integer. Hence the "Definitions of property procedures for the same property are inconsistent" error message
ChewDoggie (Programmer)
30 Oct 08 6:37
It just kills me when I miss the simplest things.  There it is in front of me ...

Anyway, thank you, strongm.

Chew

10% of your life is what happens to you.  90% of your life is how you deal with it.

Reply To This Thread

Posting in the Tek-Tips forums is a member-only feature.

Click Here to join Tek-Tips and talk with other members!

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