Imports System.IO
Imports System
Public Class Form1
Private Class movie
Public name As String
Public actors() As String
Public year As String
Public country As String
Public votes As String
End Class
Private movies(0) As movie
Private fs As FileStream
Private input As StreamReader
Private Sub LoadToolStripMenuItem_Click(ByVal sender As System.Object, ByVal e As System.EventArgs) Handles LoadToolStripMenuItem.Click
OpenFileDialog1.ShowDialog()
Dim i As Integer = 0
Dim currentmv As New movie
Dim reader As String()
If File.Exists(OpenFileDialog1.FileName) Then
lblPath.Text = OpenFileDialog1.FileName
Dim iFile As New StreamReader(lblPath.Text)
While Not iFile.EndOfStream
reader = iFile.ReadLine.Split(";")
currentmv.name = reader(0)
currentmv.actors = reader(1).Split(",")
currentmv.year = reader(2)
currentmv.country = reader(3)
currentmv.votes = reader(4)
lbMovies.Items.Add(currentmv.name)
movies(i) = currentmv
i = i + 1
ReDim movies(i)
End While
End If
End Sub
Private Sub lbMovies_SelectedIndexChanged(ByVal sender As System.Object, ByVal e As System.EventArgs) Handles lbMovies.SelectedIndexChanged
Dim i As Integer
For i = 0 To movies(lbMovies.SelectedIndex).actors.Length
lbActors.Items.Add(movies(lbMovies.SelectedIndex).actors(i))
Next
End Sub
End Class
길이를 요청할 때 문제가 발생합니다. 그것은 그것은 null 참조라고하지만, 이것에 어떤 실수를 볼 수 없습니다. 객체 배열에서 배열의 길이를 요청할 때 문제가 있습니까?미스터리 null 참조
당신이 예외가 어디에 실제로 지점에서로드 된 파일을 했습니까? 디버깅을 시도 할 때 어떤 일이 발생 했습니까? –