Well, store you picturebox's in a list(of <t>). Then use the random class to generate a random integer from 0 to that list's count in a timer's tick event with the interval set to 1000. Finally toggle that item's visibility. Here is an example, not tested, free handed:
Like I said, I free typed this and didn't test it, but it gives you an idea.Code:Option Strict On Option Explicit On Public Class Form1 Private pb_List As New List(Of PictureBox) Private r As New Random Private shown As Boolean = False Private Sub Form_Load(ByVal sender As Object, ByVal e As EventArgs) Handles Form1.Load 'Loop through each picturebox on the form For Each pb As PictureBox In Me.Controls.OfType(Of PictureBox)() pb_List.Add(pb) Next Dim tmr As New Timer tmr.Interval = 1000 '1 Second 'Event Handler AddHandler tmr.Tick, AddressOf Timer_Tick End Sub Private Sub Timer_Tick(ByVal sender As Object, ByVal e As EventArgs) 'Static, not dimmed Static i As Integer If Not (shown) Then i = r.Next(0, pb_List.Count) End If 'shown is now what it wasn't then shown = Not (shown) 'If shown then the pb is visible, and vise versa pb_List.Item(i).Visible = shown End Sub End Class




Reply With Quote