VB 2010多维数组,思想块

时间:2012-05-14 02:30:22

标签: vb.net-2010

所以我试图在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

1 个答案:

答案 0 :(得分:0)

你不是Initializing你的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)