1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 20 21 22 23 24 25 26 27 28 29 30 31 32 33 34 35 36 37 38 39 40 41 42 43 44 45 46 47 48 49 50
|
Public Class Form1
Dim AlPhotos As New ArrayList
Dim AlSequence As New ArrayList
Dim NbrdePhotos As Integer = 0
Dim IntCount As Integer = 0
Private Sub Form1_Load(sender As Object, e As EventArgs) Handles MyBase.Load
'Chargement de l'arraylist des chemins de photos ex: C: ...... blablabla
AlPhotos.Add("Pierre")
AlPhotos.Add("Julie")
AlPhotos.Add("François")
AlPhotos.Add("Lyne")
AlPhotos.Add("Mélanie")
NbrdePhotos = AlPhotos.Count
End Sub
Function BrasserAL(ByVal Int As Integer) As ArrayList
Dim Al As New ArrayList
Randomize()
Dim Int1 As Integer = -1
Do Until Al.Count = Int + 1
Int1 = CInt(Int * Rnd())
If Not Al.Contains(Int1) Then
Al.Add(Int1)
End If
Loop
Return Al
End Function
Private Sub ToolStripButton1_Click(sender As Object, e As EventArgs) Handles ToolStripButton1.Click
'Je brasse une première séquence et je lance le timer
AlSequence = BrasserAL(NbrdePhotos - 1)
Timer1.Start()
End Sub
Private Sub Timer1_Tick(sender As Object, e As EventArgs) Handles Timer1.Tick
Console.WriteLine(IntCount)
Console.WriteLine(String.Format("À {0}:{1} affiche la photo de {2}", Now.Minute, Now.Second, AlPhotos(AlSequence(IntCount))))
IntCount += 1
'Lorsque le compteur est arrivé au nbr de photos je le remet à zéro et je brasse
'une nouvelle séquence
If IntCount = NbrdePhotos Then
IntCount = 0
AlSequence = BrasserAL(NbrdePhotos - 1)
Console.WriteLine("_-_-_-_-_-_-_-_-_-_-_-_-_-_-_-_-_-_-_-_-_-")
End If
End Sub
End Class |
Partager