Random ENUM?

  • Thread starter Thread starter Grahmmer
  • Start date Start date
G

Grahmmer

Hey all!

Just wondering if there is an easy way to generate a random ENUM?

For example...

txtInput.Dock = DockStyle.RandomStyleHere

....how would I write this in VB.Net code to tell the textbox to dock with a
random side (or fill, or none)?
 
I'm not going to write if for you but, yes check out the Random.Next(
Int32 ) member function of the random class. This will get you where you
need to be.

Regards - OHM
 
Grahmmer said:
Hey all!

Just wondering if there is an easy way to generate a random ENUM?

For example...

txtInput.Dock = DockStyle.RandomStyleHere

...how would I write this in VB.Net code to tell the textbox to dock
with a random side (or fill, or none)?

Add the styles to an array and use Rnd (Microsoft.VisualBasic.VBMath.Rnd) or
System.Random to create a random index. Then use the index to select the
style in the array.
 
Good enough for me!

One Handed Man said:
I'm not going to write if for you but, yes check out the Random.Next(
Int32 ) member function of the random class. This will get you where you
need to be.
 
Back
Top