DialogResult and Vb warning

Warning 1 Access of shared member, constant member, enum member or nested type through an instance; qualifying expression will not be evaluated. D:\data\IeI\gp\AppCom\IeFinMgr\FormIeFinMgr.vb 742 29 IeFinMgr

code:

Dim od As New OpenDialog()

Dim myDialogResult As DialogResult = od.ShowDialog(Me)
If myDialogResult = DialogResult.OK Then
ShowUrl(od.PathOrUrl)
End If

however the above did work. How should I code so I don't get the warning on DialogResult.OK



Answer this question

DialogResult and Vb warning

  • sapo

    You are getting this warning because the form has a DialogResult property. Of course, you are using the enumerated type name here, not the property. The compiler ought to be smart enough to pick the type name, not the property. And it is. Just not quite smart enough to suppress the warning. To avoid it the warning, spell it out (like IntelliSense does):
    If myDialogResult = Windows.Forms.DialogResult.OK Then


  • sroughley

    great tips. thank you. you also taught me how to get rid of simlar complaint next time!
  • DialogResult and Vb warning