Private Sub btnDeal_Click(ByVal sender As System.Object, ByVal e As System.EventArgs) Handles btnDeal.Click Me.lblHand.Text = "" Me.lblResult.Text = "" Dim rndNum As Random = New Random() Dim intX, intY As Integer Dim intCardNum As Integer Dim intSuitNum As Integer Dim intFaceNum As Integer Dim intHandIndex As Integer = 0 Dim Suits As String() = New String() {"Hearts", "Diamonds", _ "Clubs", "Spades"} Dim Faces As String() = New String() {"Ace", "Deuce", "Three", _ "Four", "Five", "Six", "Seven", "Eight", "Nine", "Ten", _ "Jack", "Queen", "King"} Dim HandStrength As String() = New String() {"Nothing Special", "There is a pair", _ "There are two pairs", "There is three of a kind", "There is a full house", _ "There is four of a kind"} Dim Deck(51) As Integer Dim myHand(4) As String Dim myHandNumeric(4) As Integer Dim myHandPairs(3) As Integer 'fill For nValue As Integer = 0 To Deck.Length - 1 Deck(nValue) = nValue + 1 Next 'mix For nLoop As Integer = 1 To 1000 Dim nLeft As Integer = rndNum.Next(0, Deck.Length - 1) Dim nRight As Integer = rndNum.Next(0, Deck.Length - 1) Dim nSwap As Integer = Deck(nLeft) Deck(nLeft) = Deck(nRight) Deck(nRight) = nSwap Next 'deal hand For nLoop As Integer = 0 To myHand.Length - 1 myHandNumeric(nLoop) = Deck(nLoop) myHand(nLoop) = Faces((Deck(nLoop) \ 13)) + " of " + Suits(CType(Math.Floor(Deck(nLoop) / 13), Integer)) Next 'show hand For nCard As Integer = 0 To myHand.Length - 1 Me.lblHand.Text += myHand(nCard) + ControlChars.CrLf Next Dim valueMatches() As Integer = {0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0} Dim suitMatches() As Integer = {0, 0, 0, 0} For Each card As Integer In myHandNumeric valueMatches(card \ 13) += 1 suitMatches(CType(Math.Floor(card / 13), Integer)) += 1 Next Dim nPairs As Integer = 0 Dim nThreeKind As Integer = 0 Dim nFourKind As Integer = 0 For Each value As Integer In valueMatches Select Case value Case 2 nPairs += 1 Case 3 nThreeKind += 1 Case 4 nFourKind += 1 End Select Next Dim bFlush As Boolean = False For Each suit As Integer In suitMatches If (suit = 5) Then bFlush = True Next With Me.lblResult If (nPairs > 0) Then .Text += String.Format("There are {0} pairs", nPairs) If (nThreeKind > 0) Then .Text += String.Format("There are {0} three-of-a-kinds ", nThreeKind) If (nFourKind > 0) Then .Text += String.Format("There are {0} four-of-a-kinds ", nFourKind) End With End Sub