Tutorials‎ > ‎VB Tutorials‎ > ‎

Get User Screen Resolution

posted Jan 14, 2010, 8:36 PM by Tim Key   [ updated Jan 14, 2010, 8:37 PM ]

There are a couple of ways to do this but the basic principle is the same.  Here are a couple of ways to do this:

 

1) As a string function

    Public Function ScreenResolution() As String
        Dim X As Integer = Screen.PrimaryScreen.Bounds.Width
        Dim Y As Integer = Screen.PrimaryScreen.Bounds.Height
        Return X & " x " & Y
    End Function

 

2) Broken down into two different functions

    Public Function ScreenWidth() As Integer
        Dim X As Integer = Screen.PrimaryScreen.Bounds.Width
        Return X
    End Function

    Public Function ScreenHeight() As Integer
        Dim Y As Integer = Screen.PrimaryScreen.Bounds.Height
        Return Y
    End Function

 

3) Copy and paste the below code into your own function or procedure and use it that way.

        Dim X As Integer = Screen.PrimaryScreen.Bounds.Width
        Dim Y As Integer = Screen.PrimaryScreen.Bounds.Height

Comments