Friday, August 6, 2010

C# Tutorial: Random Number Generator

Here is the code

int count; Random rnd = new Random();
count = 0; label4.Text = ""; timer1.Start();
label4.Text = rnd.Next(Convert.ToInt32(textBox1.Text), Convert.ToInt32(textBox2.Text)).ToString();
if (count > Convert.ToInt32(textBox3.Text)) { timer1.Stop(); label4.Text = "Your number is: " + label4.Text; }

Or download the solution

1 comment:

  1. Hello,

    Will be good if we can create an animation or actual numbers scrolling fast through a small box in the app, e.g like 1,2,3,4,5,6,2,3,4,5,6,7,4,3,4,5, when the user presses run. Then it stops on random number when stopped is pressed e.g: 4.

    Yes it will remind you of gambling!