While Not sr.EndOfStream
line = sr.ReadLine
If line.Contains("Year") Then
currentYear = line.ToString
ElseIf line.Contains("mandatory") Then
moduleStats = "M"
ElseIf line.Contains("optional") Then
moduleStats = "O"
ElseIf line.Contains("COM") Then
modArray = sr.ReadLine.Split(",")
' Dim i As Integer = modArray.Length
'ReDim Preserve modArray(modArray.Length + 2) 'ReDim statement to change the size of one or more dimensions of an array,
'Preserve you can resize that dimension and still preserve all the contents of the array
' modArray(i) = moduleStats
' modArray(i + 1) = currentYear.ToString()
MsgBox(String.Join(",", modArray))
End If
End While
我已经注释掉了很多代码,但是它每隔一秒就会返回一次记录,我不知道为什么!Any1帮帮我好吗??请注意,我如何拆分文档并不重要,这是文档的布局。
第一年
必填
COM137,计算数学,2,20
COM140,计算机技术,1-2,20
COM147,数据库简介,1-2,20
COM163,专业实践,1-2,20
COM180,编程I,2,10
第二年
必填
COM319,网络和数据通信,1-2,10
因此,它从阅读计算机技术行开始,这是不应该的,然后跳转到下一个数据库简介行
发布于 2012-01-24 04:09:28
看起来是因为你调用了ReadLine
两次。
尝试更改:
modArray = sr.ReadLine.Split(",")
所以它是这样写的:
modArray = line.Split(",")
https://stackoverflow.com/questions/8977864
复制相似问题