Screen Dimensions in Visual Basic

自作多情 提交于 2019-12-10 04:18:46

问题


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

标签
易学教程内所有资源均来自网络或用户发布的内容,如有违反法律规定的内容欢迎反馈
该文章没有解决你所遇到的问题?点击提问,说说你的问题,让更多的人一起探讨吧!