Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

Screen Dimensions in Visual Basic

How can you access the dimensions of the screen in Visual Basic? I have looked online and it says to use Screen.width and Screen.length, but it doesn't recognize those properties... any tips?

like image 244
Monkeyanator Avatar asked Oct 21 '11 01:10

Monkeyanator


1 Answers

In VB you can use Screen.Width and Screen.Height. They're not in VBA but you can use an API call instead. Add these declarations:

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

Then use like so:

MsgBox GetSystemMetrics(SM_CXSCREEN) & "x" & GetSystemMetrics(SM_CYSCREEN)
like image 113
Boann Avatar answered Oct 14 '22 17:10

Boann