How do I take a screenshot in VB.net 2005

B

Bob

Dim objRectangle As Rectangle = Screen.PrimaryScreen.Bounds

Dim objBitmap As New Bitmap(objRectangle.Right, objRectangle.Bottom)

Dim objGraphics As Graphics

objGraphics = objGraphics.FromImage(objBitmap)

Last line wont evaluate in Vs 2005, worked OK in 2003

Thanks for help

Bob
 
L

Larry Lard

Bob said:
Dim objGraphics As Graphics

objGraphics = objGraphics.FromImage(objBitmap)

Last line wont evaluate in Vs 2005, worked OK in 2003
(it helps to say what error message you get - I am assuming you are
getting "Access of shared member, constant member, enum member or
nested type through an instance; qualifying expression will not be
evaluated.")


FromImage is a Shared method of Graphics - that is it 'belongs' to the
class, not to any particular instance. Pre-VB2005, this (technically
incorrect) syntax of invoking class methods through an instance was
allowed without comment. In VB2005, it is by default a warning. The
correct syntax is

objGraphics = Graphics.FromImage(objBitmap)
 

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