-1

所以我试图在visual basic 2010中制作纸牌游戏WAR。我有以下代码,我知道下一步我需要做什么,但我无法进入下一步。

Public Class form1
'throws an error unless this is the first class in the file

    Private Sub Button1_Click(ByVal sender As System.Object, ByVal e As System.EventArgs) Handles Button1.Click
        'click the button currently labled "loop"
        Dim Cards() As String = {"Ace", "2", "3", "4", "5", "6", "7", "8", "9", "10", "Jack"} 'spades,hearts/diamonds,clubs
        Dim Values() As String = {"11", "2", "3", "4", "5", "6", "7", "8", "9", "10", "11"} 'faces is a term meaning a card that depicts a person
        Dim suits() As String = {"H", "D", "C", "S"}
        Dim p1deck()() As String '
        'first (0) is the number of the array
        'second(0) is the string
        p1deck(0)(0) = "Ace"
        p1deck(0)(1) = "11"
        p1deck(0)(2) = "Hearts"

        TextBox1.Text = p1deck(0)(0) & " of " & p1deck(0)(2)

        'Cards.ToList().  add/removeAt
    End Sub
End Class
4

1 回答 1

0

你没有初始化你的 p1deck 数组。

尝试这样的事情:

Dim p1deck(2, 3) As String 

p1deck(0, 0) = "Ace"
p1deck(0, 1) = "11"
p1deck(0, 2) = "Hearts"

TextBox1.Text = p1deck(0, 0) & " of " & p1deck(0, 2)
于 2012-05-14T02:52:45.280 回答