尝试将列从excel导入到我的列表框中以vb.net格式时出现中断错误
问题是在将列中的所有项目成功导入列表框之后。出现中断错误并关闭程序。 这是中断错误
An unhandled exception of type 'System.ArgumentNullException' occurred
in System.Windows.Forms.dll
Additional information: Value cannot be null))
这是我的代码
Private Sub Button5_Click(sender As Object, e As EventArgs) Handles Button5.Click
Dim oExcel As Object = CreateObject("Excel.Application")
Dim oBook As Object = oExcel.Workbooks.Open("C:\Users\User\Desktop\1.xlsx")
Dim oSheet As Object = oBook.Worksheets(1)
Dim i As Integer
Dim cell As String
For i = 0 To AscW(ListBox1.Items.Count.ToString()(i = i + 1))
cell = "E" & Convert.ToString(i + 1)
cell = oSheet.Range(cell).Value
ListBox1.Items.Add(cell)
Next
oExcel.Quit()
End Sub