Hi,
i am try to read from a file and then split the data and store them in array
but i am getting an error. can someone please point to the right direction
here is the file i am trying to read from
8
223432,YNYYYYYYYYYNYNYNYYNY-
623123,YNYNYNYYNY--YNYNYYNY
912234,YYYNYNYNYNYYNYYNYYNY
612356,YYYNYFYNYYNYYNYYNYYN
165478,YYYNYYYYY-NYYNYYNYYN
612321,YYYNYFYNYYNYYNYYNYYN
165213,YYYNYYYYY-NYYNYYNYYN
my code is as below
Dim Result As DialogResult
Dim strFileName As String
Dim sreStreamReader As IO.StreamReader
Dim strRecord As String
Dim strRecord1 As string
Dim strField(1) As string
Dim intCount As Integer = 0
Dim mstrName(7) As string
Dim mintMark(7) As string
Try
Result = OpenStudentResponsesFile.ShowDialog
If (Result = Windows.Forms.DialogResult.OK) Then
strFileName =OpenStudentResponsesFile.FileName
'open file
sreStreamReader = IO.File.OpenText(strFileName)
strRecord = sreStreamReader.ReadLine()& vbNewLine
MessageBox.Show (strRecord)
'read file
While (sreStreamReader.Peek <> -1)
strRecord1 = sreStreamReader.ReadLine()
strField = strRecord1.Split(",")
mstrName(intCount) = strField(0)
mintMark(intCount) =strField(1)
intCount = intCount + 1
lbldisplay.Text=strField(1)
End While
sreStreamReader.Close()
End If
Catch ex As Exception
MessageBox.Show (ex.Message)
End Try
End Sub