Query shared members

Query shared members

Old forum URL: forums.lhotka.net/forums/t/2530.aspx


Wal972 posted on Thursday, March 15, 2007

Hi

Can someone please explain why I need to have two different wording because I get the following error

Access of shared member, constant member, enum member or nested type through an instance; qualify expression will not be evaluated.

Private mEmployeeDetail As EmployeeDetail = Library.EmployeeDetail.NewEmployeeDetail

Protected mTaxDetail As TaxDetail = Library.TaxDetail.NewTaxDetail

Protected mAddressDetail As AddressDetail = AddressDetail.NewAddresDetail

Thanks for the help

Ellie

jhw replied on Thursday, March 15, 2007

I don't understand your question Ellie, can you explain it more? Are you talking about calling a shared method via an instance instead of the class?

JoeFallon1 replied on Thursday, March 15, 2007

Ellie,

It isn't clear from your post when or where you are getting the error message.

This looks correct to me:

Protected mTaxDetail As TaxDetail = Library.TaxDetail.NewTaxDetail

 

You could get that message if you incorrectly coded it like this: (Note the use of mTaxDetail on the right side.)

Protected mTaxDetail As TaxDetail = mTaxDetail.NewTaxDetail

Joe

 

Wal972 replied on Thursday, March 15, 2007

Access of shared member, constant member, enum member or nested type through an instance; qualify expression will not be evaluated.

Sorry for the confusion.

Private mEmployeeDetail As EmployeeDetail = Library.EmployeeDetail.NewEmployeeDetail

works but if I have

Private mEmployeeDetail As EmployeeDetail = EmployeeDetail.NewEmployeeDetail

then the error occurs. Yet

Protected mAddressDetail As AddressDetail = AddressDetail.NewAddresDetail

works

What is that all about ?

malloc1024 replied on Thursday, March 15, 2007

Are you calling this code in a class that contains a shared property called EmployeeDetail?  If so, you should include Library.  The reason for this is if you omit Library, the code:


Private mEmployeeDetail As EmployeeDetail = EmployeeDetail.NewEmployeeDetail


Really is (notice the Me.)


Private mEmployeeDetail As EmployeeDetail = Me.EmployeeDetail.NewEmployeeDetail.


It is incorrect to call a shared property from an instance.  As a result, you will get this error.

Wal972 replied on Thursday, March 15, 2007

Thanks so much, I had unintentionally done just that. I could find an explain in the help so I couldn't work out the problem

The property for the EmployeeDetail within the Employee Class had the same name as the child class EmployeeDetail.

Thanks, thanks thanks, it has driven me nuts off and on for ages but never found the problem

Ellie

Copyright (c) Marimer LLC