问题
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?
回答1:
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)
来源:https://stackoverflow.com/questions/7844171/screen-dimensions-in-visual-basic