Anzeige
Anzeige
HERBERS
Excel-Forum (Archiv)
20+ Jahre Excel-Kompetenz: Von Anwendern, für Anwender
Inhaltsverzeichnis

Per Zufall Image laden

Forumthread: Per Zufall Image laden

Per Zufall Image laden
amintire
Hallo alle zusammen,
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
Anzeige

2
Beiträge zum Forumthread
Beiträge zu diesem Forumthread

Betreff
Benutzer
Anzeige
AW: Per Zufall Image laden
30.09.2011 09:23:25
Rudi
Hallo,
z.B.

Private Sub SpinButton1_Change()
Dim iPic As Integer
Randomize
iPic = Int((UBound(arrFotos) + 1) * Rnd)
Image1.Picture = LoadPicture(arrFotos(iPic))
Label1 = iPic
TextBox1 = arrFotos(iPic)
Repaint
.....

Gruß
Rudi
AW: Danke ;)
30.09.2011 11:08:22
amintire
Gruß Amina
Anzeige
;

Beliebteste Forumthreads (12 Monate)

Anzeige
Anzeige
Anzeige