Getting Screen Resolution


'Getting Screen Resolution

'Code By Kiran Reddy
'Getting Screen Resolution
'You can get screen resolution in two ways
'One is using GetSystemMetrics another is using TwipsPerPixel
'Declaration

Private Declare Function GetSystemMetrics Lib "user32.dll" (ByVal nIndex As Long) As Long
Private Const SM_CXSCREEN = 0
Private Const SM_CYSCREEN = 1

Private Sub Form_Load()
'getting screen resolution with GetSystemMetrics
MsgBox "Current Screen Resolution is " & GetSystemMetrics(SM_CXSCREEN) & " x " & GetSystemMetrics(SM_CYSCREEN)

' Or you can use below

'best way is using Screen.TwipsPerPixel

MsgBox "Current Screen Resolution is " & Screen.Width / Screen.TwipsPerPixelX & " x " & Screen.Height / Screen.TwipsPerPixelY
End Sub
You can view this article online at:
http://www.kiranreddys.com/knowledgebase/index.php/article/getting-screen-resolution