Public Class clsCard Public Structure typCard Dim mark As String Dim num As Integer Dim img As Bitmap End Structure Public Enum enMark SPADE = 0 DIA CLOVER HEART End Enum Public cardMark() As String = {"s", "d", "c", "h"} Private cardList(51) As typCard Private index As Integer Sub New() index = 0 Dim n As Integer = 0 For m As Integer = enMark.SPADE To enMark.HEART For i As Integer = 1 To 13 cardList(n).mark = cardMark(m) cardList(n).num = i cardList(n).img = My.Resources.ResourceManager.GetObject(String.Format("{0}{1:00}", cardMark(m), i)) n += 1 Next Next End Sub Public Sub shuffle() Dim rnd As New Random For i As Integer = cardList.Length - 1 To 1 Step -1 Dim x As Integer = rnd.Next(i) Dim tmp As typCard = cardList(i) cardList(i) = cardList(x) cardList(x) = tmp Next End Sub Public Sub reset() index = 0 End Sub Public Function nextCard() As typCard Dim ret As typCard = New typCard ret.num = -1 If index < cardList.Length Then ret = cardList(index) index += 1 End If Return ret End Function Public Function restCard() As Integer Return 52 - index End Function End Class