excel - Display image for a Listbox selection
问题描述
I am trying to display an image for each listbox item if it is selected.
The 'boss.jpg' is located in a desktop folder called 'VBA', I have yet to add additonal listbox items or pictures to the folder until I can get the 'boss.jpg' image to display properly.
Option Explicit
Private Sub Image1_BeforeDragOver(ByVal Cancel As MSForms.ReturnBoolean, _
ByVal Data As MSForms.DataObject, ByVal X As Single, ByVal Y As Single, _
ByVal DragState As MSForms.fmDragState, ByVal Effect As MSForms.ReturnEffect, _
ByVal Shift As Integer)
Dim picPath As String
Dim strPath As String
strPath = "C:\Users\Jason\Desktop\VBA"
picPath = strPath & "Boss\" & Image1.Value & ".jpg"
imgPictures.Picture = LoadPicture(picPath)
End Sub
Private Sub UserForm_Initialize()
ListBox1.AddItem "boss"
ListBox1.AddItem "Keep off grass"
End Sub
解决方案
推荐阅读
- r - R - 机器学习:分类响应变量的子集选择包和方法
- spring - Spring WS 没有为 Endpoint 类中的所有公共方法生成 wsdl 操作
- android - 如何在实现 swipeRefreshLayout 时防止用户滚动?
- python - 随机打乱训练目标数据后查找特征的 ROC 分数的函数不是随机的
- excel - 如果某个范围内的单元格具有值“x”,则将一系列单元格复制并粘贴到不同的工作表中
- tableau-api - 如何在默认情况下将工作表显示为空白并且仅在单击操作后显示结果?画面
- android - 了解 Activity 和 Service 的生命周期
- python - 如何在dict之前解析python b'
- r - 使用 subplot 结合静态和动画的 plotly 对象
- c# - 在 IIS 上配置 .net core web 应用程序和 webapi