Blackjack randomizing an array help

Collapse
X
 
  • Time
  • Show
Clear All
new posts
  • EXotiX
    New Member
    • Jun 2007
    • 2

    Blackjack randomizing an array help

    hey im new to vb6 and I am making a blackjack game but can not randomize the array correctly. Could you help please

    [CODE=vb]Option Explicit
    Const NumItems As Integer = 53

    Public Sub RandomizeCards( )
    Dim i As Integer
    Dim j As Integer
    Dim tmp As Integer

    ' Randomize the array.
    Randomize
    For i = 1 To NumItems - 1
    ' Pick a random entry.
    j = Int((NumItems - i + 1) * Rnd + i)

    ' Swap the numbers.

    imgCards(j) = imgCards(i)
    imgCards(tmp) = imgCards(j)
    imgCards(i) = imgCards(tmp)
    Next i

    imgUser(0) = imgCards(j)
    imgUser(1) = imgCards(i)
    End Sub

    Private Sub cmdDeal_Click()
    RandomizeCards
    End Sub[/CODE]

    I have zipped the program as well for you to look at.

    Last edited by Killer42; Jun 19 '07, 10:00 AM. Reason: Added [CODE=vb] tag
  • Killer42
    Recognized Expert Expert
    • Oct 2006
    • 8429

    #2
    Just from a quick glance, my guess is that lines 17 to 19 are in the wrong sequence.

    Comment

    Working...