Get Screen Resolutions in vb.net

Posted on 2012-08-13
Medium Priority
Last Modified: 2012-09-27
I'd like to determine the display resolution for each connected monitor in a multimonitor setup. It seems there are a few ways to do this, but I can't seem to find an example for implementing it in vb.net. Thanks for your help!
Question by:Aaron Feledy
LVL 35

Expert Comment

by:Robert Schutt
ID: 38287516
I use this (adjusted from a routine found on the net) to determine the form size needed to cover all screens (for a screensaver):
        Dim EntireBounds As New Rectangle(0, 0, 0, 0)
        Dim scrn As Integer
        Dim TheScreens() As Screen = Screen.AllScreens
        For scrn = LBound(TheScreens) To UBound(TheScreens)
            If TheScreens(scrn).Bounds.X + TheScreens(scrn).Bounds.Width > EntireBounds.Width Then
                EntireBounds.Width = TheScreens(scrn).Bounds.X + TheScreens(scrn).Bounds.Width
            End If
            If TheScreens(scrn).Bounds.Y + TheScreens(scrn).Bounds.Height > EntireBounds.Height Then
                EntireBounds.Height = TheScreens(scrn).Bounds.Y + TheScreens(scrn).Bounds.Height
            End If
        Next scrn
        Me.Bounds = EntireBounds

Open in new window

The essence is the For Next loop, if you need to do something with each screen separately then inside the loop is the place to be ;-)
LVL 28

Accepted Solution

Ark earned 2000 total points
ID: 38291010
       For Each scrn As Screen In Screen.AllScreens
            Debug.Print(scrn.Bounds.Width & "x" & scrn.Bounds.Height)

Open in new window

LVL 13

Author Closing Comment

by:Aaron Feledy
ID: 38439172
Simple and does exactly what I need.

Featured Post

Independent Software Vendors: We Want Your Opinion

We value your feedback.

Take our survey and automatically be enter to win anyone of the following:
Yeti Cooler, Amazon eGift Card, and Movie eGift Card!

Question has a verified solution.

If you are experiencing a similar issue, please ask a related question

It’s quite interesting for me as I worked with Excel using vb.net for some time. Here are some topics which I know want to share with others whom this might help. First of all if you are working with Excel then you need to Download the Following …
It was really hard time for me to get the understanding of Delegates in C#. I went through many websites and articles but I found them very clumsy. After going through those sites, I noted down the points in a easy way so here I am sharing that unde…
Please read the paragraph below before following the instructions in the video — there are important caveats in the paragraph that I did not mention in the video. If your PaperPort 12 or PaperPort 14 is failing to start, or crashing, or hanging, …
Is your data getting by on basic protection measures? In today’s climate of debilitating malware and ransomware—like WannaCry—that may not be enough. You need to establish more than basics, like a recovery plan that protects both data and endpoints.…
Suggested Courses

850 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