0
我想將文本框中的每個數字數字添加到列表(整數),但我需要使用integer.Parse將其轉換爲正確的格式,但這樣做會收到「未設置爲對象實例的對象引用」錯誤。 我的代碼如下:在for循環VB中添加項目(Of)VB
Dim key As List(Of Integer)
Dim digit As Integer
Private Sub Button1_Click(sender As System.Object, e As System.EventArgs) Handles Button1.Click
For Each c As Char In TextBox1.Text
digit = Integer.Parse(c)
key.Add(digit)
Next
End Sub
'Dim'只聲明瞭你想要一個名爲'key'變量是'名單(的Int32)已'。它不會創建集合對象。 – Plutonix