PDA

View Full Version : [SOLVED] add random picture to Image in Userform



petroj02
09-29-2016, 04:55 AM
Hello everyone,

is it possible somehowe to add random Picture from Folder, where I have saved Pictures for example (picture1.jpg,picture2.jpg....) to Image in userform? For example I have 30 Images so something like this...
for i =1 to 30
me("Image" & i).Picture=LoadPicture("C:\User\Images\random pick")
next

random pick is randomly Chosen Picture...
Thank you for help

petroj02
09-29-2016, 05:19 AM
Problem solved on my own... here is clue just for 4 pictures
Private Sub CommandButton1_Click()
Dim x As Integer
Randomize
x = Int(4 * Rnd) + 1
For i = 1 To 30
Me("Image" & i).Picture = LoadPicture("V:\CGC_DATA\Images\picture" & x & ".jpg")
x = Int(4 * Rnd) + 1
Next
End Sub