title: How to display deck of cards and compare for doubles
body: <p>So..  right now I am having a pretty big problem. I have my pictures of a card deck but they are not displaying at all when the deal button is clicked. They were being displayed initially, but I tweaked something and now they are not.. There will be 3 players, this is the test code for player one. Right now it is only set for 16 cards, but you get the idea.</p>
  
  <p>Also, how do I compare to check for doubles and then remove them to a discard pile? Please help, I am beyond my capabilities at this point and I really have no idea how to proceed. Thanks!!</p>
  
  <p>Deckofcardstest</p>
  
  <pre><code>Public Class DeckOfCardsTest
      Dim playercards As Integer = 16
      Dim playermatches As Integer
      Dim comp1cards As Integer
      Dim comp1matches As Integer
      Dim comp2cards As Integer
      Dim comp2matches As Integer
  
  
      Private deck As New DeckOfCards() ' create the deck of cards
  
  
      Private Sub dealButton_Click(ByVal sender As System.Object,
         ByVal e As System.EventArgs) Handles dealButton.Click
          discard1PictureBox.Visible = True
  
          deck.Shuffle() ' shuffles the deck
  
          Dim card1 = deck.DealCard()
          card1PictureBox.Image = GetCardImage(card1)
  
          Dim card2 = deck.DealCard()
          card2PictureBox.Image = GetCardImage(card2)
  
          Dim card3 = deck.DealCard()
          card3PictureBox.Image = GetCardImage(card3)
  
          Dim card4 = deck.DealCard()
          card4PictureBox.Image = GetCardImage(card4)
  
          Dim card5 = deck.DealCard()
          card5PictureBox.Image = GetCardImage(card5)
  
          Dim card6 = deck.DealCard()
          card6PictureBox.Image = GetCardImage(card6)
  
          Dim card7 = deck.DealCard()
          card7PictureBox.Image = GetCardImage(card7)
  
          Dim card8 = deck.DealCard()
          card8PictureBox.Image = GetCardImage(card8)
  
          Dim card9 = deck.DealCard()
          card9PictureBox.Image = GetCardImage(card9)
  
          Dim card10 = deck.DealCard()
          card10PictureBox.Image = GetCardImage(card10)
  
          Dim card11 = deck.DealCard()
          card11PictureBox.Image = GetCardImage(card11)
  
          Dim card12 = deck.DealCard()
          card12PictureBox.Image = GetCardImage(card12)
  
          Dim card13 = deck.DealCard()
          card13PictureBox.Image = GetCardImage(card13)
  
          Dim card14 = deck.DealCard()
          card14PictureBox.Image = GetCardImage(card14)
  
          Dim card15 = deck.DealCard()
          card15PictureBox.Image = GetCardImage(card15)
  
          Dim card16 = deck.DealCard()
          card16PictureBox.Image = GetCardImage(card16)
  
          lblPlayerCards.Text = CStr(playercards)
  
  
  
  
      End Sub ' dealButton_Click
  
      ' return an image for the Card argument
      Private Function GetCardImage(ByVal card As Card) As Image
          If card IsNot Nothing Then
              ' retrieve specific card image from resources
              Dim pictureResource = My.Resources.ResourceManager.GetObject(
                card.ToString().Replace(" ", ""))
              Return CType(pictureResource, Image) ' return Image
          Else
              dealButton.Enabled = False ' disable the Deal Button
              Return Nothing ' no more cards
          End If
  
  
  
      End Function ' GetCardImage
  
      Private Sub btnQuick_Click(ByVal sender As System.Object, ByVal e As System.EventArgs) Handles btnQuick.Click
          discard1PictureBox.Visible = True
  
  
          deck.Shuffle() ' shuffles the deck
  
          Do
  
  
              Dim card1 = deck.DealCard()
              card1PictureBox.Image = GetCardImage(card1)
  
              Dim card2 = deck.DealCard()
              card2PictureBox.Image = GetCardImage(card2)
  
              MessageBox.Show("Thank you for playing")
              dealButton.Enabled = False
              btnQuick.Enabled = False
          Loop
      End Sub
  
  
  End Class ' DeckOfCardsTest
  </code></pre>
  
  <p>card</p>
  
  <pre><code>Public Class Card
  
      Public Enum CardValue
          Ace = 1
          Two = 2
          Three = 3
          Four = 4
          Five = 5
          Six = 6
          Secen = 7
          Eight = 8
          Nine = 9
          Ten = 10
          Jack = 11
          Queen = 12
          King = 13
      End Enum
  
      Public Enum CardSuit
          Clubs
          Spades
          Hearts
          Diamonds
      End Enum
  
      Public Property Value As CardValue
      Public Property Suit As CardSuit
  
      Public Sub New(ByVal value As CardValue, ByVal suit As CardSuit)
          Me.Value = value
          Me.Suit = suit
      End Sub
  
  End Class
  </code></pre>
  
  <p>deckofcards</p>
  
  <pre><code>Public Class DeckOfCards
     Private Const NUMBER_OF_CARDS As Integer = 52 ' number of cards
     Private deck(NUMBER_OF_CARDS - 1) As Card ' array of Card objects
     Private currentCard As Integer ' index of next Card to be dealt
     Private Shared randomNumbers As New Random() ' random number generator
  
     ' constructor fills deck of Cards
     Public Sub New()
        Dim faces() As String = {"Ace", "Two", "Three", "Four", "Five",
           "Six", "Seven", "Eight", "Nine", "Ten", "Jack", "Queen", "King"}
        Dim suits() As String = {"Hearts", "Diamonds", "Clubs", "Spades"}
          currentCard = 0 ' set currentCard so first Card dealt is deck(0)
  
  
  
          Dim deck(51) As Card
          Dim cardPosition As Integer = 0
  
          'loop through each suit and each value in that suit setting one of the deck to that   
          For Each suit As Card.CardSuit In [Enum].GetValues(GetType(Card.CardSuit))
              For Each value As Card.CardValue In [Enum].GetValues(GetType(Card.CardValue))
                  deck(cardPosition) = New Card(value, suit)
                  cardPosition += 1
              Next
          Next
  
  
  
     End Sub ' New
  
     ' shuffle deck of Cards with simple one-pass algorithm
     Public Sub Shuffle()
        ' after shuffling, dealing should start at deck(0) again
        currentCard = 0 ' reinitialize currentCard
  
        ' for each Card, pick another random Card and swap them
        For first = 0 To deck.GetUpperBound(0)
           ' select a random number between 0 and 51
           Dim second As Integer = randomNumbers.Next(NUMBER_OF_CARDS)
  
           ' swap current Card with randomly selected Card
           Dim temp As Card = deck(first) ' store copy of deck(first)
           deck(first) = deck(second) ' move deck(second) to deck(first)
           deck(second) = temp ' move original deck(first) to deck(second)
        Next
     End Sub ' Shuffle
  
     ' deal one Card
     Public Function DealCard() As Card
        ' determine whether Cards remain to be dealt
        If currentCard &lt;= deck.GetUpperBound(0) Then
           Dim lastCard As Integer = currentCard ' store current card number
           currentCard += 1 ' increment current card number
           Return deck(lastCard)
        Else
           Return Nothing ' no more cards to deal
          End If
  
  
  
      End Function ' DealCard
  
  
  End Class ' DeckOfCards
  </code></pre>