I am wanting to create a card game that will have 1 to 7 players plus the dealer. Currently I have 1 player and the dealer. Each player will have a listbox that contains an index for each card in the player's hand. As the cards are dealt each player will be dealt their first card including the dealer, the dealer being last. Then everyone is dealt their second card again the dealer being last. What i need is a way to save the contents of the listbox for each player and when it's that player's turn to recieve another card the repopulate the listbox with the previously saved items and then add the new itemas it is dealt to the player. Could be used in many types of card games.

You could store each player's cards in an array and assign the ListBox DataSource as needed. Here is an example:

Public Class Form1

    Private list1() As String
    Private list2() As String

    Private Sub Form1_Load(sender As System.Object, e As System.EventArgs) Handles MyBase.Load

        list1 = {"a", "b", "c", "d", "e"}
        list2 = {"f", "g", "h", "i", "j"}

    End Sub

    Private Sub Button1_Click(sender As System.Object, e As System.EventArgs) Handles Button1.Click
        ListBox1.DataSource = list1
    End Sub

    Private Sub Button2_Click(sender As System.Object, e As System.EventArgs) Handles Button2.Click
        ListBox1.DataSource = list2
    End Sub

End Class

Thanks Rev, Your code lead my in the right direction. Sorry it took so long to reply. I've been working on some other aspects of the game and it took longer than anticipated.

This question has already been answered. Start a new discussion instead.