Hello,
My user form titled "sinkinformation" has an image box and a combo box. I'd like the image box to display an image based on what is selected from combo box, titled "sinkstyle".
The following is the code I am using. The problem I encounter is that the combo box will not display the list of file names from the file path specified in the code (C:\sinkstyle). Obviously this means that if the image's file name doesn't populate in the list, there's nothing to select to display that image.
Private Sub sinkinformation_Initialize()
Application.ScreenUpdating = False
Dim fA()
Dim i%, n%
Dim dName$
ChDrive "c"
ChDir "C:\sinkstyle"
dName = Dir("*.jpg")
Do While dName <> ""
n = n + 1
ReDim Preserve fA(1 To n)
fA(n) = dName
dName = Dir()
Loop
For i = 1 To n
sinkstyle.AddItem Left(fA(i), Application.Find(".", fA(i)) - 1)
Next
Application.ScreenUpdating = True
End Sub
Private Sub sinkstyle_change()
Image1.Picture = LoadPicture(sinkstyle.Value & ".jpg")
End Sub
I have checked the accuracy of the file path name, file type (.jpg), and other obvious possible errors which might cause this issue.
Please let me know if any additional information is needed to better understand my question or code I am using.
Thank you very much!
Bookmarks