3 Replies - 387 Views - Last Post: 29 May 2011 - 06:28 PM Rate Topic: -----

#1 ssharma286  Icon User is offline

  • D.I.C Head

Reputation: 6
  • View blog
  • 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  Icon User is offline

  • Critical Section
  • member icon



Reputation: 1746
  • View blog
  • 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
Was This Post Helpful? 1
  • +
  • -

#3 Btu  Icon User is offline

  • D.I.C Head

Reputation: 34
  • View blog
  • 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.
Was This Post Helpful? 0
  • +
  • -

#4 AdamSpeight2008  Icon User is offline

  • MrCupOfT
  • member icon


Reputation: 1998
  • View blog
  • 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.
Was This Post Helpful? 0
  • +
  • -

Page 1 of 1