Advertisement
Guest User

Untitled

a guest
Jan 10th, 2016
142
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
  1. Private Sub cmdExit_Click()
  2.     Unload Me
  3. End Sub
  4.  
  5. Private Sub cmdInstructions_Click()
  6.     lblTitle.Visible = True
  7.     lblInstructions.Visible = True
  8. End Sub
  9.  
  10. Private Sub cmdPlay_Click()
  11.     lblInstructions.Visible = False
  12.     lblTitle.Visible = False
  13.  
  14.    
  15. End Sub
  16.  
  17. Private Sub Form_Load()
  18.         lblInstructions.Visible = False
  19.        
  20. End Sub
  21.  
  22. ' This function requires you to pass in a string of varying lengths and shuffles the characters along with their suit in
  23. ' that string and returns them.
  24. Private Function ShuffleWithSuits(StrDeck As String) As String
  25.    'Variable Table-------------------------------------------
  26.   ' strCard - String - the single, randomly selected card that gets shuffled to the back
  27.   ' strRightCards - String - all cards to the right of strCard
  28.   ' strLeftCards - String - all cards to the left of strCard
  29.   ' intNumberCardsDeck - integer - the number of cards in the deck to shuffle
  30.   ' counter - integer - to be used as a counter in a counted loop
  31.  
  32.     Dim strCard As String
  33.     Dim strRightCards As String
  34.     Dim strLeftCards As String
  35.     Dim intNumberCardsDeck As Integer
  36.     Dim intRandomNumber As Integer
  37.     Dim counter As Integer
  38.     Dim Player1Cards As String
  39.     Dim Player2Cards As String
  40.    
  41.      'Unshuffled deck.  Note that I used A=10, B=Jack, C=Queen, D=King, E=Ace
  42.    'to identify suits h=hearts, d=Diamonds, c=Clubs, s=Spades
  43.    StrDeck = "2h3h4h5h6h7h8h9hAhBhChDhEh2d3d4d5d6d7d8d9dAdBdCdDdEd2c3c4c5c6c7c8c9cAcBcCcDcEc2s3s4s5s6s7s8s9sAsBsCsDsEs"
  44.     Debug.Print  StrDeck
  45.  
  46.     'call the subroutine to shuffle the deck
  47.    StrDeck = ShuffleWithSuits(StrDeck)
  48.    
  49.     Debug.Print  StrDeck
  50.     'Determine the number cards in the deck
  51.    intNumberCardsDeck = Len(StrDeck) / 2
  52.  
  53.     'Shutffle cards the cards by randomly selecting a card and moving it to the back of the deck
  54.    For counter = 1 To 200
  55.         intRandomNumber = Int((52 - 1 + 1) * Rnd + 1)
  56.         intRandomNumber = (intRandomNumber * 2) - 1
  57.    
  58.         'Take the card at position intRandomNumber and move it to the bottom of deck
  59.        'Do move the card if it's the card at bottom of the deck
  60.        If intRandomNumber <> 52 Then
  61.             strLeftCards = Left(StrDeck, intRandomNumber - 1)
  62.             strCard = Mid(StrDeck, intRandomNumber, 2)
  63.             strRightCards = Right(StrDeck, 104 - intRandomNumber - 1) 'not sure if it should be -intRandomNubmer
  64.            
  65.             'Put random card at the bottom of deck
  66.            StrDeck = strLeftCards + strRightCards + strCard
  67.         End If
  68.     Next counter
  69.    
  70.     ' the Function is complete, returns the value stored in StrDeck to the function call
  71.    ShuffleWithSuits = StrDeck
  72.    
  73. End Function
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement