Advertisement
Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- Private Sub cmdExit_Click()
- Unload Me
- End Sub
- Private Sub cmdInstructions_Click()
- lblTitle.Visible = True
- lblInstructions.Visible = True
- End Sub
- Private Sub cmdPlay_Click()
- lblInstructions.Visible = False
- lblTitle.Visible = False
- End Sub
- Private Sub Form_Load()
- lblInstructions.Visible = False
- End Sub
- ' This function requires you to pass in a string of varying lengths and shuffles the characters along with their suit in
- ' that string and returns them.
- Private Function ShuffleWithSuits(StrDeck As String) As String
- 'Variable Table-------------------------------------------
- ' strCard - String - the single, randomly selected card that gets shuffled to the back
- ' strRightCards - String - all cards to the right of strCard
- ' strLeftCards - String - all cards to the left of strCard
- ' intNumberCardsDeck - integer - the number of cards in the deck to shuffle
- ' counter - integer - to be used as a counter in a counted loop
- Dim strCard As String
- Dim strRightCards As String
- Dim strLeftCards As String
- Dim intNumberCardsDeck As Integer
- Dim intRandomNumber As Integer
- Dim counter As Integer
- Dim Player1Cards As String
- Dim Player2Cards As String
- 'Unshuffled deck. Note that I used A=10, B=Jack, C=Queen, D=King, E=Ace
- 'to identify suits h=hearts, d=Diamonds, c=Clubs, s=Spades
- StrDeck = "2h3h4h5h6h7h8h9hAhBhChDhEh2d3d4d5d6d7d8d9dAdBdCdDdEd2c3c4c5c6c7c8c9cAcBcCcDcEc2s3s4s5s6s7s8s9sAsBsCsDsEs"
- Debug.Print StrDeck
- 'call the subroutine to shuffle the deck
- StrDeck = ShuffleWithSuits(StrDeck)
- Debug.Print StrDeck
- 'Determine the number cards in the deck
- intNumberCardsDeck = Len(StrDeck) / 2
- 'Shutffle cards the cards by randomly selecting a card and moving it to the back of the deck
- For counter = 1 To 200
- intRandomNumber = Int((52 - 1 + 1) * Rnd + 1)
- intRandomNumber = (intRandomNumber * 2) - 1
- 'Take the card at position intRandomNumber and move it to the bottom of deck
- 'Do move the card if it's the card at bottom of the deck
- If intRandomNumber <> 52 Then
- strLeftCards = Left(StrDeck, intRandomNumber - 1)
- strCard = Mid(StrDeck, intRandomNumber, 2)
- strRightCards = Right(StrDeck, 104 - intRandomNumber - 1) 'not sure if it should be -intRandomNubmer
- 'Put random card at the bottom of deck
- StrDeck = strLeftCards + strRightCards + strCard
- End If
- Next counter
- ' the Function is complete, returns the value stored in StrDeck to the function call
- ShuffleWithSuits = StrDeck
- End Function
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement