detecting screen resolution in VB.NET

I'd like to find a VB.NET library containing the object that would allow me to detect screen resolution in VB.NET. I'd like to do it with a native VB.NET method, not via VB6 compatibility.

Who is Participating?

Improve company productivity with a Business Account.Sign Up

Steve SiricaConnect With a Mentor Senior Web Application EngineerCommented:
See if there's anythying in here that will help you:

    Dim Index As Integer
    Dim UpperBound As Integer

    ' Gets an array of all the screens connected to the system.

    Dim Screens() As System.Windows.Forms.Screen = _
    UpperBound = Screens.GetUpperBound(0)

    For Index = 0 To UpperBound

        ' For each screen, add the screen properties to a list box.

        ListBox1.Items.Add("Device Name: " + Screens(Index).DeviceName)
        ListBox1.Items.Add("Bounds: " + Screens(Index).Bounds.ToString())
        ListBox1.Items.Add("Type: " + Screens(Index).GetType().ToString())
        ListBox1.Items.Add("Working Area: " + Screens(Index).WorkingArea.ToString())
        ListBox1.Items.Add("Primary Screen: " + Screens(Index).Primary.ToString())


And yes this is .NET code

Good luck
Steve SiricaSenior Web Application EngineerCommented:
here's what I use:
Public Function gsChkScreenRes()
    Dim XTwips      As Long
    Dim YTwips      As Long
    Dim XPixels     As Long
    Dim YPixels     As Long
    On Error GoTo Syntax_Error
    XTwips = Screen.TwipsPerPixelX
    YTwips = Screen.TwipsPerPixelY

    XPixels = Screen.Height / YTwips
    YPixels = Screen.Width / XTwips
    gsChkScreenRes = YPixels * XPixels

    Exit Function
    Resume Exit_Sub
End Function
if it returns <= Mode1 then it's 640x480 and so on.

    'Numbers of Colors in palette
    Const Mode1 = 307200    '* 640 x 480
    Const Mode2 = 480000    '* 800 x 600
    Const Mode3 = 786432    '* 1024 x 768
you can add what you need to check

Good luck
tbbrhunAuthor Commented:
I'm looking for VB.NET solution to this problem. THANKS!
Steve SiricaSenior Web Application EngineerCommented:
I didn't see that, sorry.
tbbrhunAuthor Commented:
Excellent! THANKS! I can take from here now. THANKS AGAIN!
Question has a verified solution.

Are you are experiencing a similar issue? Get a personalized answer when you ask a related question.

Have a better answer? Share it in a comment.

All Courses

From novice to tech pro — start learning today.