Error message when converting VB 2003 app to VB 2005

E

EdPoint

As I work to convert a working VB 2003 app that has no error messages to VB
2005, I have been presented with more than 100 instances of the following
warning message:

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


Can someone explain what has changed within VB that leads to this warning?
What steps should I follow to address it?
 
M

Marina

VB allows you to access shared methods through an instance of the class. I
am not sure why it does, since it doesn't make sense to do this for shared
methods anyway.

Now you just see a warning about it. All it says is that the variable you
are using to call the shared method/property is not going to get evaluated -
it is going to be ignored. The method will just be called on the class
type. So if your variable was never instantiated, it shouldn't make a
difference, since it can't and won't be used to actually call the method.

It is good practice to call shared methods on the class directory, and not
an instance of it.
 
H

Herfried K. Wagner [MVP]

EdPoint said:
As I work to convert a working VB 2003 app that has no error messages to
VB
2005, I have been presented with more than 100 instances of the following
warning message:

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


Can someone explain what has changed within VB that leads to this warning?
What steps should I follow to address it?


The simplest solution is to turn off the warning:

Select "My Project" in solution explorer, -> "Compile" -> "Instance variable
accesses shared member" -> set "Notification" to "None".

Alternatively you can change the method calls to use the name of the class
you want to call the shared member on instead of a variable.
 

Ask a Question

Want to reply to this thread or ask your own question?

You'll need to choose a username for the site, which only take a couple of moments. After that, you can post your question and our members will help you out.

Ask a Question

Similar Threads

Error in Vb express 6
Vb Net2005 putting thread to sleep 2
2005 error 5
Warning Text Files Access 5
Converting VB 2003 to VB 2005 4
IDE Warning 2
& string concat operator usasge 6
2005 Conversion Warning 2

Top