Tag Archives: screen resolution

How to get the Computer Screens Resolution using VB and VB.NET

Click Star to Rate Post
1 Star2 Stars3 Stars4 Stars5 Stars (10 votes, average: 4.20 out of 5)

At some point you may need to get a computers monitor/video resolution for sizing your applications and/or your applications controls/fonts or whatever. It is actually easy to do so in ALL versions of Visual Basic. Only a very small amount of additional code is required to get the Resolution in 6.0 compared to doing it in .NET. Below is doing it in VB 6.0.

Visual Basic 6.0

To get the resolution in VB Classic is quite easy. You can use the following code below…

Screen.Width – For the Horizonal Resolution.

Screen.Height – to get the Vertical resolution.

But if you use those codes by themselves, it will not return the resolution in Pixels which is probably the format you are wanting. There is an extra piece of code for getting the resolution in Pixels…

Screen.Width / Screen.TwipsPerPixelX

Screen.Height / Screen.TwipsPerPixelY

Below is the code put together with a Messagebox displaying the resolution for the screen…

'Simply throws a messagebox with the current resolution of the screen...
MsgBox("The Screen Resolution is: " & Screen.Width / Screen.TwipsPerPixelX & "x" & Screen.Height / Screen.TwipsPerPixelY)

What about the VB.NET versions? Even easier actually.

Visual Basic.NET & VB 2008/2010, and VB 2013

What we want is the Screen class located at:


This handy little Class has data related to the computers display screen. Below is a simply example…

'Simply display a messagebox with the resolution of the computers screen.

If a computer has more than one(1) screen/monitor, then you could also use the ‘Screen’ class to get the resolution for that screen.

Example: Say your application was running on a computer with Two(2x) monitors/displays and you wanted to know the resolution of the monitor your Form is shown on or the monitor that is showing the biggest portion of your Form? The Screen Class can help you with that…

'If you had multiple displays, and you wanted to know the resolution of the display
' that contains your form, this code would do that for you.


In Visual Basic 2005 and/or Visual Basic 2008, VB 2010, and newer you can even use the MY interface to access the Screen class.


'Use the MY shortcut in VB 05/08 to get the sacreen size...

Well, thats all there is to it if you wanted to get the Computers Display/Screen Resolution in your Applications. Its easy to do from Visual Basic 5.0/6.0 through to Visual Basic 2005/2008. Have fun! 🙂