2005 error

C

cj

The below line gives me an error on DialogResult.No saying: "Access of
shared member, constant member, enum member or nested type through an
instance; qualifying expression will not be evaluated." It didn't give
me that in 2003. What does that mean?

If MessageBox.Show("Copy from " & fromDir & " to " & toDir & " ?", "",
MessageBoxButtons.YesNo, MessageBoxIcon.Question) = DialogResult.No Then
 
G

Guest

cj,

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

Instead, use Windows.Forms.DialogResult.No to access the shared member.

Kerry Moorman
 
C

ClayB

Instead of typing DialogResult.No, type the fully qualified Shared
property:

System.Windows.Forms.DialogResult.No

===================
Clay Burch
Syncfusion, Inc.
 
H

Herfried K. Wagner [MVP]

cj said:
The below line gives me an error on DialogResult.No saying: "Access of
shared member, constant member, enum member or nested type through an
instance; qualifying expression will not be evaluated." It didn't give
me that in 2003. What does that mean?

If MessageBox.Show("Copy from " & fromDir & " to " & toDir & " ?", "",
MessageBoxButtons.YesNo, MessageBoxIcon.Question) = DialogResult.No Then

There is a name clash between the form's 'DialogResult' property and the
'DialogResult' type, and the compiler will bind to the property instead of
the type. To solve the problem, qualify the type name:

\\\
If d.ShowDialog() = System.Windows.Forms.DialogResult.OK Then
...
End If
///
 
L

Linda Liu [MSFT]

Hi Cj,

I performed a test based on your sample code but didn't reproduce the
problem on my side.

The namespace "System.Windows.Forms" is imported automatically in WinForms
application projects. In my test project, it's same whether I add the
namespace to the expression 'DialogResult.No' (i.e.
System.Windows.Forms.DialogResult.No) or not.

But you may have a try adding the namespace to the 'DialogResult.No' to see
if the problem still exists.

If the problem still exists, you may send me a sample project that could
just reproduce the problem. To get my actual email address, remove "online"
from my displayed email address.


Sincerely,
Linda Liu
Microsoft Online Community Support

==================================================
Get notification to my posts through email? Please refer to
http://msdn.microsoft.com/subscriptions/managednewsgroups/default.aspx#notif
ications.

Note: The MSDN Managed Newsgroup support offering is for non-urgent issues
where an initial response from the community or a Microsoft Support
Engineer within 1 business day is acceptable. Please note that each follow
up response may take approximately 2 business days as the support
professional working with you may need further investigation to reach the
most efficient resolution. The offering is not appropriate for situations
that require urgent, real-time or phone-based interactions or complex
project analysis and dump analysis issues. Issues of this nature are best
handled working with a dedicated Microsoft Support Engineer by contacting
Microsoft Customer Support Services (CSS) at
http://msdn.microsoft.com/subscriptions/support/default.aspx.
==================================================

This posting is provided "AS IS" with no warranties, and confers no rights.
 

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