VB.NET 2005 DialogResult.OK?

  • Thread starter Thread starter dm1608
  • Start date Start date
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?
 
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
 
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
///
 
Back
Top