VB.NET 2005 DialogResult.OK?

D

dm1608

I'm opening my own form and doing something like:

If dlgDirectory.ShowDialog() = DialogResult.OK Then
....
End If

When I compile the project, I can a warning for the line saying:

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

It looks like it has something to do with DialogResult.OK, however I've seen
other code do the same thing.

What am I doing wrong?
 
A

Armin Zingler

dm1608 said:
I'm opening my own form and doing something like:

If dlgDirectory.ShowDialog() = DialogResult.OK Then
...
End If

When I compile the project, I can a warning for the line saying:

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

It looks like it has something to do with DialogResult.OK, however
I've seen other code do the same thing.

What am I doing wrong?


Dialogresult is not only a type but also a property of the Form. Use the
FQN:

System.Windows.Forms.DialogResult.OK


Armin
 
H

Herfried K. Wagner [MVP]

dm1608 said:
If dlgDirectory.ShowDialog() = DialogResult.OK Then
...
End If

When I compile the project, I can a warning for the line saying:

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

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

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


Top