Arrays VB.net数组引发异常
下面的潜艇正在投掷 “对象引用未设置为对象的实例。” 例外Arrays VB.net数组引发异常,arrays,vb.net,for-loop,Arrays,Vb.net,For Loop,下面的潜艇正在投掷 “对象引用未设置为对象的实例。” 例外 For Each element As Song In modFiles.getSongs() Dim col(2) As String Dim item As ListViewItem col(0) = element.SongTitle col(1) = element.PlayTime col(2) = element.SongFilename item = New ListView
For Each element As Song In modFiles.getSongs()
Dim col(2) As String
Dim item As ListViewItem
col(0) = element.SongTitle
col(1) = element.PlayTime
col(2) = element.SongFilename
item = New ListViewItem(col)
setList.Items.Add(item)
Next
异常是在行上抛出的
col(0) = element.SongTitle
col(1) = element.PlayTime
col(2) = element.SongFilename
如果您忘记了数组中的一个元素,将不胜感激
Dim col(3) As String
数组中忘记了一个元素
Dim col(3) As String
您的For Each
迭代器在某处返回空对象。围绕循环体包装一个空测试
For Each element As Song In modFiles.getSongs()
If element IsNot Nothing Then
Dim col(2) As String
Dim item As ListViewItem
col(0) = element.SongTitle
col(1) = element.PlayTime
col(2) = element.SongFilename
item = New ListViewItem(col)
setList.Items.Add(item)
End If
Next
您的For Each
迭代器在某处返回空对象。围绕循环体包装一个空测试
For Each element As Song In modFiles.getSongs()
If element IsNot Nothing Then
Dim col(2) As String
Dim item As ListViewItem
col(0) = element.SongTitle
col(1) = element.PlayTime
col(2) = element.SongFilename
item = New ListViewItem(col)
setList.Items.Add(item)
End If
Next
数组绑定为0,列(2)有三项。数组绑定为0,列(2)有三项。