Welcome Guest ( Log In | Register )

      
Discover the best free computer help!
Learn more about Geeks to Go by taking the tour. Spyware, virus, trojan, fake security or privacy alerts? Read the malware cleaning guide.
 
Reply to this topicStart new topic
Random numbers, how to?
BTPH
post Jul 21 2005, 05:25 PM
Post #1


Member
***
Posts: 166
OS: XP



how do i set p (using vb.net) a button to generate a random number between the values of 15 and 35

ive defined an integer
dim X as integer
and the i did
X=RND()
this works but it only goes between 1 and 0, how do i change so it will pick a number between 15 and 35 (inclusive)?

thanks ben


hey dw bout it i found a solution on msdn.microsoft.com

if ne1s interested the solution is
CInt(Int((upperbound - lowerbound + 1) * Rnd() + lowerbound))
upperbound means highest number and lowerbound means lowest

This post has been edited by BTPH: Jul 21 2005, 05:31 PM
Go to the top of the page
 
+Quote Post
BuRnEr
post Jul 22 2005, 03:13 AM
Post #2


Member
**
Posts: 48
OS: win 98, xp pro and 2000 server



easiest and simple way to do!!!!
Random is a class in .net.
they are not real random they are only algorithm
so that makes sense you can creat your own random algorithm that generates random numbers
class abc
{
static void Main()
{
Random random=new Random(1 )// 1 is seed number pseudo random number sequence you can change it whatever you like
while(true)//you have to check the loop there are too many ways and it is your job
{
int ranNum=random.Next(100);//instead int you can change the type of variable ranNum like double it depends what is the max number you want
Console.WriteLine(ranNum);//prints random numbers put break point in this line that you can watch it slowly with pressing F5
}
}}

another way

the following code returns a random number between min and max
in this example random numbers are limited between minimum and maximum

private int RandomNumber(int min, int max)
{
Random ran=new Random();
return ran.Next(min,max);
}

takeCare
BuRnEr
Go to the top of the page
 
+Quote Post

Reply to this topicStart new topic
1 User(s) are reading this topic (1 Guests and 0 Anonymous Users)
0 Members:

 

Collapse

> Similar Topics

    Topic Title Replies / Views Topic Information
No New Posts   2 / 251 30th July 2006 - 04:33 AM
Japstar started - last by Japstar
No New Posts   1 / 202 7th July 2006 - 07:04 AM
Japstar started - last by spike_hacker_inc
No new   25 / 1,522 25th November 2006 - 10:20 AM
smile07 started - last by Kat
No New Posts   0 / 305 14th May 2008 - 06:09 AM
pepsi2000 started - last by pepsi2000

RSS Time is now: 2nd December 2008 - 08:54 AM
Advertisements do not imply our endorsement of that product or service. The forum is run by volunteers who donate their time and expertise. We make every attempt to ensure that the help and advice posted is accurate and will not cause harm to your computer. However, we do not guarantee that they are accurate and they are to be used at your own risk.