2010-11-08 62 views
1

我無法更改標籤中的文本。有人能告訴我問題在哪裏嗎?循環不會顯示錶單標籤中的文本

Public Class Form1 
    Dim Tracker As Integer = 0 
    Dim Questions(10) As String 

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

    Questions(0) = "Are you mad?" 
    Questions(1) = "Are you sad?" 
    Questions(2) = "Are you glad?" 
    Questions(3) = "Are you happy?" 
    Questions(4) = "Are you indebted?" 
    Questions(5) = "Are you swimming in money?" 
    Questions(6) = "Do you play sports?" 
    Questions(7) = "Do you watch SportsCenter?" 
    Questions(8) = "Do you cheer for the Pistons?" 
    Questions(9) = "Do you cheer for the Lions?" 


End Sub 

Private Sub Button1_Click(ByVal sender As System.Object, ByVal e As System.EventArgs) 
Handles Button1.Click 
    Button1.Text = "Next" 

    For i = 0 To Questions.Length - 1 

     Label1.Text += Questions(i) 
    Next 

End Sub 

End Class 
+0

以上代碼的輸出是什麼? – Mudassir 2010-11-08 05:49:02

+0

空白標籤,當它應該顯示相應的問題 – Isaac 2010-11-08 05:58:38

回答

1

我只是使用按鈕單擊來增加計數器變量,然後將該變量設置爲數組索引。