How to start a random Timer after a condition is met?
First of all, is something like that even possible because I don't really know. Second, anyone got any ideas?
I want to do smth like instead of typing
I can type
where A is a random integer declared before.
Re: How to start a random Timer after a condition is met?
If you have multiple timers you could add them to a list, then use a random number from zero to the list count to select which timer to start, try something like...
Code:
Private myTimers As New List(Of Timer)
Private rand As New Random
Private Sub Form1_Load(sender As System.Object, e As System.EventArgs) Handles MyBase.Load
' add timers to the list
myTimers.AddRange({Timer1, Timer2, Timer3})
End Sub
Private Sub Button1_Click(sender As System.Object, e As System.EventArgs) Handles Button1.Click
' get random number between zero and our timers list count
Dim index As Integer = rand.Next(0, myTimers.Count)
' start the timer
myTimers(index).Start()
End Sub