我正在尝试为每个列表框项目显示一个图像。
“ boss.jpg”位于名为“ VBA”的桌面文件夹中,在我可以正常显示“ boss.jpg”图像之前,我还没有向该文件夹添加其他列表框项目或图片。
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