Removing Images from PictureBox Array

BradWoj

New member
Joined
Jan 27, 2012
Messages
1
Programming Experience
Beginner
I'm working on creating a card game, and I've gotten as far a drawing cards (storing them in a PictureBox array) and showing them in a PictureBox on the main form. I can draw more cards, and clear the array, but the images remain on the form.

Here's my code:
VB.NET:
Private Sub Deal(ByVal numtodraw As Int16)
        Dim numbertodraw As Int16 = numtodraw


        Dim i As Integer = 0
        While (i < numbertodraw)
            'Draw from the top of the deck
            ReDim Preserve Hand(CardsInHandCnt)
            Hand(CardsInHandCnt) = Deck(0)


            'Remove top card of deck
            Deck(0) = Deck(UBound(Deck))
            ReDim Preserve Deck(UBound(Deck) - 1)


            ReDim CardTrack(CardsInHandCnt)
            CardTrack(CardsInHandCnt) = New PictureBox
            CardTrack(CardsInHandCnt).Image = Image.FromFile("..\..\images\" & Hand(CardsInHandCnt).ToString & ".png")
            CardTrack(CardsInHandCnt).Parent = pbxHand
            CardTrack(CardsInHandCnt).Left = CardsInHandCnt * 75 + 1
            CardTrack(CardsInHandCnt).Top = 5
            CardTrack(CardsInHandCnt).Height = 96
            CardTrack(CardsInHandCnt).Width = 72
            CardTrack(CardsInHandCnt).Name = "Card" & CardsInHandCnt


            AddHandler CardTrack(CardsInHandCnt).MouseDoubleClick, AddressOf Card_Drawn
            CardsInHandCnt = CardsInHandCnt + 1


            i = i + 1
        End While
    End Sub

How can I remove the images from the form?
Thanks!
 
Back
Top