petroj02
09-30-2016, 05:23 AM
Hello everyone,
I am looking for help.... I would like to generate automaticly 15 random and unique Pictures for Image...
so far I have this code, It can eveń overwrite some Images but not the one which was correct before the wrong one... I feel i Need Little push up...
Private Sub CommandButton1_Click()
Dim x As Integer
Dim counter As Integer
Dim priznak(1 To 15) As Integer
counter = 1
Randomize
x = Int(15 * Rnd) + 1
For i = 1 To 15
If i = 1 Then
Me("Image" & i).Picture = LoadPicture("V:\CGC_DATA\Images\picture" & x & ".jpg")
Me("Image" & i).Tag = x
priznak(i) = x
ElseIf i > 1 Then
Me("Image" & i).Picture = LoadPicture("V:\CGC_DATA\Images\picture" & x & ".jpg")
Me("Image" & i).Tag = x
priznak(i) = x
For j = 1 To i - 1
If priznak(j) = priznak(i) Then
MsgBox "Already exist"
End If
Do While priznak(j) = priznak(i)
x = Int(15 * Rnd) + 1
Me("Image" & i).Picture = LoadPicture("V:\CGC_DATA\Images\picture" & x & ".jpg")
Me("Image" & i).Tag = x
priznak(i) = x
Loop
Next
End If
x = Int(15 * Rnd) + 1
Next
End Sub
everyones help would be welcome
I am looking for help.... I would like to generate automaticly 15 random and unique Pictures for Image...
so far I have this code, It can eveń overwrite some Images but not the one which was correct before the wrong one... I feel i Need Little push up...
Private Sub CommandButton1_Click()
Dim x As Integer
Dim counter As Integer
Dim priznak(1 To 15) As Integer
counter = 1
Randomize
x = Int(15 * Rnd) + 1
For i = 1 To 15
If i = 1 Then
Me("Image" & i).Picture = LoadPicture("V:\CGC_DATA\Images\picture" & x & ".jpg")
Me("Image" & i).Tag = x
priznak(i) = x
ElseIf i > 1 Then
Me("Image" & i).Picture = LoadPicture("V:\CGC_DATA\Images\picture" & x & ".jpg")
Me("Image" & i).Tag = x
priznak(i) = x
For j = 1 To i - 1
If priznak(j) = priznak(i) Then
MsgBox "Already exist"
End If
Do While priznak(j) = priznak(i)
x = Int(15 * Rnd) + 1
Me("Image" & i).Picture = LoadPicture("V:\CGC_DATA\Images\picture" & x & ".jpg")
Me("Image" & i).Tag = x
priznak(i) = x
Loop
Next
End If
x = Int(15 * Rnd) + 1
Next
End Sub
everyones help would be welcome