Strange BC42025 warning

Posted on 2006-04-20
Last Modified: 2008-02-01
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?
Question by:AlexFM
    LVL 12

    Accepted Solution

           If e.Button = Windows.Forms.MouseButtons.Left Then

    LVL 12

    Expert Comment

    The Left that you think is working for you is the forms left property
    LVL 12

    Expert Comment

    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

    LVL 48

    Author Comment

    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.
    LVL 12

    Expert Comment

    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

    Featured Post

    How to run any project with ease

    Manage projects of all sizes how you want. Great for personal to-do lists, project milestones, team priorities and launch plans.
    - Combine task lists, docs, spreadsheets, and chat in one
    - View and edit from mobile/offline
    - Cut down on emails

    Join & Write a Comment

    Suggested Solutions

    This tutorial demonstrates one way to create an application that runs without any Forms but still has a GUI presence via an Icon in the System Tray. The magic lies in Inheriting from the ApplicationContext Class and passing that to Application.Ru…
    1.0 - Introduction Converting Visual Basic 6.0 (VB6) to Visual Basic 2008+ (VB.NET). If ever there was a subject full of murkiness and bad decisions, it is this one!   The first problem seems to be that people considering this task of converting…
    Get a first impression of how PRTG looks and learn how it works.   This video is a short introduction to PRTG, as an initial overview or as a quick start for new PRTG users.
    This video gives you a great overview about bandwidth monitoring with SNMP and WMI with our network monitoring solution PRTG Network Monitor ( If you're looking for how to monitor bandwidth using netflow or packet s…

    733 members asked questions and received personalized solutions in the past 7 days.

    Join the community of 500,000 technology professionals and ask your questions.

    Join & Ask a Question

    Need Help in Real-Time?

    Connect with top rated Experts

    24 Experts available now in Live!

    Get 1:1 Help Now