# Random Number failure

Page 1 of 1

## 3 Replies - 387 Views - Last Post: 29 May 2011 - 06:28 PMRate Topic: //<![CDATA[ rating = new ipb.rating( 'topic_rate_', { url: 'http://www.dreamincode.net/forums/index.php?app=forums&module=ajax&section=topics&do=rateTopic&t=233891&amp;s=a6dd22c7fde07c9f4b2c23a606f6b745&md5check=' + ipb.vars['secure_hash'], cur_rating: 0, rated: 0, allow_rate: 0, multi_rate: 1, show_rate_text: true } ); //]]>

### #1 ssharma286

Reputation: 6
• Posts: 93
• Joined: 04-December 10

# Random Number failure

Posted 29 May 2011 - 11:27 AM

I am trying to make a texas hold em game and it is of the utmost importance that my code generate a random number. But using a random number function that I always end up with a lot of the same numbers over and over again. Any ideas on how to make it "TRULY" random? My current code is below:
``` Dim e As Integer
Dim b As String
e = Random(1, 57)
For counter = 1 To e
b = Random(1, 1000)
b = b Mod 53

Next
If (b = 0) Then b = Random(1, 43)
```

and the function is....
```Function Random(ByVal Lowerbound As Long, ByVal Upperbound As Long)
Randomize()
Random = Int(Rnd * Upperbound) + Lowerbound
End Function
```

Is This A Good Question/Topic? 0

## Replies To: Random Number failure

### #2 smohd

• Critical Section

Reputation: 1746
• Posts: 4,409
• Joined: 14-March 10

## Re: Random Number failure

Posted 29 May 2011 - 11:34 AM

Why dont you use a build in random generator, like declare an instance of random and use it to give next number

### #3 Btu

Reputation: 34
• Posts: 244
• Joined: 16-May 11

## Re: Random Number failure

Posted 29 May 2011 - 06:08 PM

just FYI, the random number generator in VB is "pseudo" random, and will never generate a truly random number.

• MrCupOfT

Reputation: 1998
• Posts: 8,808
• Joined: 29-May 08

## Re: Random Number failure

Posted 29 May 2011 - 06:28 PM

There is more than one Random number source in VB.net.