TkHaddad
TkHaddad

Reputation: 13

Can I get a random button to blink in vb.net?

I'm creating a game where you have to click buttons in a certain sequence. I want the buttons to blink in order at the beginning so the player could take a look at the sequence and memorize it.. on each round, the buttons get assigned new values, hence the order changes,

I want to be able to make any button blink, meaning instead of writing button1, I wanna be able to use button(i) (if it's possible)

thanks in advance!

Upvotes: 0

Views: 315

Answers (1)

sloth
sloth

Reputation: 101072

You can put all your buttons that should blink into a list, then create a random number, and use this random number to get the button at this index.

Dim buttons = new Button() {button1, button2, button3} 'Put buttons into list

Dim r = new Random()
Dim seq_length = 3 'Let three buttons blink

For i = 0 To seq_length
    Dim index = r.Next(0, buttons.Count()) 'Get random index
    LetButtonBlink(buttons(index)) 'Use this index to select a button
Next

Upvotes: 1

Related Questions