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?

[Product update] Infrastructure Analysis Tool is now available with Business Accounts.Learn More

I wear a lot of hats...

"The solutions and answers provided on Experts Exchange have been extremely helpful to me over the last few years. I wear a lot of hats - Developer, Database Administrator, Help Desk, etc., so I know a lot of things but not a lot about one thing. Experts Exchange gives me answers from people who do know a lot about one thing, in a easy to use platform." -Todd S.

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.
Steve SiricaSenior 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

Experts Exchange Solution brought to you by

Your issues matter to us.

Facing a tech roadblock? Get the help and guidance you need from experienced professionals who care. Ask your question anytime, anywhere, with no hassle.

Start your 7-day free trial
tbbrhunAuthor Commented:
Excellent! THANKS! I can take from here now. THANKS AGAIN!
It's more than this solution.Get answers and train to solve all your tech problems - anytime, anywhere.Try it for free Edge Out The Competitionfor your dream job with proven skills and certifications.Get started today Stand Outas the employee with proven skills.Start learning today for free Move Your Career Forwardwith certification training in the latest technologies.Start your trial today
Visual Basic Classic

From novice to tech pro — start learning today.