gpt4 book ai didi

image - 如何清除用户窗体中的图像?

转载 作者:行者123 更新时间:2023-12-04 21:10:02 27 4
gpt4 key购买 nike

我有一个使用图像控件的用户窗体。我根据两个标准在此控件中显示图片。
当我想输入两个新条件时,我不知道如何在用户窗体中清除此图像。

最佳答案

您可以通过 Image1.Picture = LoadPicture(vbNullString) 轻松“清除”您的 UserForm Image 控件(例如 Image1) .在下面的示例中,您将在单击命令按钮时在显示定义的图片和显示空控件之间切换。为了控制图像状态(是否为空),您可以通过 If Image1.Picture Is Nothing Then 检查图像图片属性。 ...
用户表单模块 (Excel) 中的代码示例

Option Explicit

Private Sub CommandButton1_Click()
' Purpose: Change view between given image and no image
Dim sImgName As String ' picture name string
sImgName = "C:\Temp\MyPicture.gif"" ' <<< choose your picture name"
With Me.Image1
If .Picture Is Nothing Then ' picture property has been cleared already
.Picture = LoadPicture(sImgName)
Else ' a picture is already displayed
.Picture = LoadPicture(vbNullString) ' clear it now
End If
End With
End Sub
在 MS Access 中使用的提示
请注意 MS Access 中重复 @DrMarbuse 的评论作为后期编辑的不同用途:

In Access 2010, the picture is directly set by the image path. So LoadPicture() shall not be used anymore (In Excel it is required). Everything stayed the same and worked like a charm.

关于image - 如何清除用户窗体中的图像?,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/47619363/

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