• Status: Solved
  • Priority: Medium
  • Security: Public
  • Views: 1164
  • Last Modified:

Strange BC42025 warning

Private Sub PictureBox1_MouseDown(ByVal sender As System.Object, ByVal e As System.Windows.Forms.MouseEventArgs) Handles PictureBox1.MouseDown
        If e.Button = MouseButtons.Left Then
            ...

This code gives the following warning in VB 8.0:
warning BC42025: Access of shared member, constant member, enum member or nested type through an instance; qualifying expression will not be evaluated.

After changing to:
If e.Button = Left Then

there is no warning. I find this warning extremly stupid: does Microsoft want to encourage using enumeration members without qualified names? Except of this, MouseButtons is not instance.
Is there way to correct this without removing qualified name, and what does really VB compiler want?
0
AlexFM
Asked:
AlexFM
  • 4
1 Solution
 
gbzhhuCommented:
       If e.Button = Windows.Forms.MouseButtons.Left Then

works
0
 
gbzhhuCommented:
The Left that you think is working for you is the forms left property
0
 
gbzhhuCommented:
I believe the trouble is that MouseButtons is a shared property and cannot be called without qualifying with class or struct.  this property is in class Forms

You can import

Imports System.Windows

then Forms.MouseButtons.Left   will work

0
 
AlexFMAuthor Commented:
Windows.Forms.MouseButtons.Left fixes this problem. Your second post is also right.
But I still think that this is VB compiler bug, because MouseButtons is not property in this context, this is enumeration. Your third post explains the reason of this bug, compiler is confused because there is also such property. Great work, thanks.
0
 
gbzhhuCommented:
No probs Alex.  I am glad to be of help to those I consider superior to me in their .NET adventure ;-)

I didn't realise the bug until your post which makes sense.  Thanks for the grade A  I am chuffed
0

Featured Post

Free Tool: Subnet Calculator

The subnet calculator helps you design networks by taking an IP address and network mask and returning information such as network, broadcast address, and host range.

One of a set of tools we're offering as a way of saying thank you for being a part of the community.

  • 4
Tackle projects and never again get stuck behind a technical roadblock.
Join Now