.NET 2.0 Conversion Wizard Flags Me.Cursor?

L

Learnicus

Hi

As per subject when using the converter wizard in vs2005 to convert vb 1.1
to 2.0 code i get warnings (lots of them) about silly stuff like
Me.Cursor.Current.

It says

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

How does me.cursor qualify for this treatment and what does it mean if i
choose to do nothing about it. The code compilies fine.

Thanks

Lenny
 
G

Guest

VB allows you to access a shared method with an instance - in your example
"Me" is the instance. The "Cursor" property is a shared property however, so
there's no need to use an instance - just use the class. VS is simply
informing you that the "Me" will not be evaluated - useless message in this
case, but if your instance term was more complicated then it could be
informative.

Accessing shared members via an instance is sloppy. I think the warning is
there now to gradually wean people off the practice since perhaps Microsoft
will remove this capability in VB in the future? (just guessing)
--
David Anton
www.tangiblesoftwaresolutions.com
Instant C#: VB to C# converter
Instant VB: C# to VB converter
Instant C++: C# to C++ converter & VB to C++ converter
Instant J#: VB to J# converter
 
G

Guest

Lenny,

Since Current is a shared property of the Cursor class, you just need to use
Cursor.Current instead of your form's instance of the Cursor class.

Kerry Moorman
 
L

Learnicus

Thats excellent. Thanks you both.

I got a bit confused because prior to posting I looked up the status of the
System.Form.Cursor. This is an overridable instance property not a shared
property so i couldn't figure out what VS was on about.
I couldn't work out why this was flagged given that Me is an instance and so
is Me.Cursor... anyways got it now.

Any idea how to turn these green under line sqiggles warnings off, i looked
in Tools/Options and im showing all settings but i cant see the option. I'll
deal with it later but for now i dont want the distraction.

Thanks

Lenny
 
A

Armin Zingler

Learnicus said:
Thats excellent. Thanks you both.

I got a bit confused because prior to posting I looked up the status
of the System.Form.Cursor. This is an overridable instance property
not a shared property so i couldn't figure out what VS was on about.
I couldn't work out why this was flagged given that Me is an
instance and so is Me.Cursor... anyways got it now.

Any idea how to turn these green under line sqiggles warnings off, i
looked in Tools/Options and im showing all settings but i cant see
the option. I'll deal with it later but for now i dont want the
distraction.


You can change it in the project's properties.


Armin
 

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

Top