wie muss ich meinen Code anpassen das mir die Images (Bilder) nach dem Zufall angezeigt werden ?
Bis jetzt ist es so das er mir die Alphabetisch zeigt wie im Ordner abgespeichert.
Der Code momentan ist:
Option Explicit
Dim arrFotos
Dim arrFotos1
Private Sub SpinButton1_Change()
Image1.Picture = LoadPicture(arrFotos(SpinButton1))
Label1 = SpinButton1 + 1
TextBox1 = arrFotos(SpinButton1)
Repaint
Dim vartmp As Variant
With Tabelle1 'Daten
vartmp = Application.Match(TextBox1.Text, .Range("A:A"), 0)
If Not IsError(vartmp) Then
Me.Tag = vartmp
TextBox2.Text = .Cells(vartmp, 2).Value
CheckBox1.Caption = .Cells(vartmp, 3).Value
CheckBox2.Caption = .Cells(vartmp, 4).Value
CheckBox3.Caption = .Cells(vartmp, 5).Value
CheckBox4.Caption = .Cells(vartmp, 6).Value
CheckBox5.Caption = .Cells(vartmp, 7).Value
Else
Me.Tag = ""
TextBox2.Text = ""
CheckBox1 = ""
CheckBox2 = ""
CheckBox3 = ""
CheckBox4 = ""
CheckBox5 = ""
End If
End With
End Sub
Private Sub UserForm_Activate()
Dim oFotos As Object, sFile As String
Dim sPath As String
sPath = Sheets("Bildpfad").Cells(2, 2) & "Kein Foto\"
Set oFotos = CreateObject("Scripting.Dictionary")
Dim Verz As String
Verz = Sheets("Bildpfad").Cells(2, 2)
sFile = Dir(Verz & "*.jpg")
Do While sFile ""
oFotos(Verz & sFile) = 0
sFile = Dir
Loop
arrFotos = oFotos.keys
SpinButton1.Max = oFotos.Count - 1
TextBox1 = arrFotos(0)
Image1.Picture = LoadPicture(arrFotos(0))
Label1 = "1"
Label2 = oFotos.Count
End Sub
Ist es auch möglich das mir per SpinButton nur 25 Bilder per Zufall angezeigt werden ?Vielen Dank für Eure Hilfe.
Gruß Amina