General discussion
February 25, 2011 at 03:51 AM
dsloet

generate 3 different numbers in Visual Basic

by dsloet . Updated 15 years, 6 months ago

Hi all,

Picture this:

You see three buttons which all contains a one digit number (1, 2 and 3) at the start of running a program. There is one other button stating “Randomize” and when you hit this randomize button all the three buttons that were first containing 1, 2 and 3 are now shuffled in a random order like 2, 3 and 1.

I was hoping to sort this out with the following code but it didn’t actually work:

Dim a, b, c, d, x As Integer

a = Button2.Text
b = Button3.Text
c = Button4.Text
d = a And b And c
Randomize()
x = Int((4 – 1) * Rnd() + 1)

Do
d = x
Loop Until a <> b <> c

Does anyone know how to do this trick?

Thanks a lot in advance!

Cheers,

Diederik

This discussion is locked

All Comments