Error in Vb express


J

Jack Russell

I have the following

If MyOpenFiledialog1.ShowDialog = DialogResult.OK then


This works fine in VB2003 but in express I get the warning

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

What does this mean / what is wrong?

Thanks

Jack Russell
 
H

Hal Rosser

Jack Russell said:
I have the following

If MyOpenFiledialog1.ShowDialog = DialogResult.OK then


This works fine in VB2003 but in express I get the warning

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

What does this mean / what is wrong?
It works in VB2005 express on my machine
 
Ad

Advertisements

M

Mr. Arnold

Jack Russell said:
I have the following

If MyOpenFiledialog1.ShowDialog = DialogResult.OK then


This works fine in VB2003 but in express I get the warning

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

What does this mean / what is wrong?
There is nothing wrong. It's new in VS 2005, where as, you don't have to
instantiate an object to use one of its methods.

<Copied an example>
This means that the method log writeEntry does not require an instanced
object to run. It is a shared method and therefore you simply need to
specify the classname and method to use.

System.Diagnostics.EventLog.WriteEntry(mcstServiceName, "Remoting Host
Service has shut down", EventLogEntryType.Warning, 71)


A shared method is much like a sub in a module - you don't need to create an
instantiate object to use the method.

<Copied>
 
G

Guest

Jack,

When you use DialogResult you are referencing the form's DialogResult
property, which is an instance of DialogResult.

To get rid of the warning message, use Windows.Forms.DialogResult.OK.

Kerry Moorman
 
H

Herfried K. Wagner [MVP]

Jack Russell said:
I have the following

If MyOpenFiledialog1.ShowDialog = DialogResult.OK then


This works fine in VB2003 but in express I get the warning

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

What does this mean / what is wrong?

The 'DialogResult' on the right side of the '=' is not considered to be a
type name because the type name is hidden by the form's 'DialogResult'
property. In VB it's generally possible to access members of a class which
are marked as 'Shared' (or member of an enumeration type) via a reference to
an instance of the type. The form's 'DialogResult' property contains an
instance of the type 'DialogResult'. 'OK' is a member of an enumeration
type, namely 'DialogResult'.

You can either disable the warning newly introduced in VB 2005, or you can
qualify the type name on the right hand side of the assignment in order to
prevent it to be bound to the form's property:

\\\
Imports WinForms = System.Windows.Forms
....
If ... = WinForms.DialogResult.OK Then
...
End If
///
 
J

Jack Russell

Kerry said:
Jack,

When you use DialogResult you are referencing the form's DialogResult
property, which is an instance of DialogResult.

To get rid of the warning message, use Windows.Forms.DialogResult.OK.

Kerry Moorman


:
Thanks, why do MS keep making life more complex (no need to answer that
question!)
 
Ad

Advertisements

J

Jack Russell

Thanks Herfried, glad you are still helping old duffers like me!
 

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

Top