gpt4 book ai didi

vba - Visual Basic 中的屏幕尺寸

转载 作者:行者123 更新时间:2023-12-04 10:56:20 25 4
gpt4 key购买 nike

如何在 Visual Basic 中访问屏幕的尺寸?我在网上看了一下,它说要使用 Screen.width 和 Screen.length,但它不能识别这些属性......有什么提示吗?

最佳答案

在VB中你可以使用Screen.WidthScreen.Height .它们不在 VBA 中,但您可以改用 API 调用。添加这些声明:

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

然后像这样使用:
MsgBox GetSystemMetrics(SM_CXSCREEN) & "x" & GetSystemMetrics(SM_CYSCREEN)

关于vba - Visual Basic 中的屏幕尺寸,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/7844171/

25 4 0
Copyright 2021 - 2024 cfsdn All Rights Reserved 蜀ICP备2022000587号
广告合作:1813099741@qq.com 6ren.com