Im using Visual Studio Express 2010
My code


What I basically want is it to give a random number from 1-7.
I know im somehow close

your question seems to belong and it is not place so post your question to related place
and then we will try to solve the issue

Try :

Dim MyRnd as New Random
TextBox1.Text = MyRnd.Next(1, 8))

But you have to seed it first by calling Randomize(). To save you the headache later, the method

MyRnd.Next(lowInt32, HighInt32)

returns a random integer in the range (lowInt32, HighInt32-1) so the statement

MyRnd.Next(1, 8)

will give you a number from 1 to 7. I would love it if anyone could give me a rational explanation of why you have to give a high value of NUM+1 in order to get a number from LOW to NUM. It seems completely brain dead to me but perhaps there is a logical explanation.

Be a part of the DaniWeb community

We're a friendly, industry-focused community of 1.18 million developers, IT pros, digital marketers, and technology enthusiasts learning and sharing knowledge.