【发布时间】:2016-11-22 00:06:52
【问题描述】:
我已经建立了一个从报告中读取数据的项目,它曾经可以正常工作,但现在由于某种原因,报告将所有内容都放入了字符串中。所以我想修改我的流阅读器以在读取行时删除或忽略引号。
这是读取行的部分的片段。
Dim RawEntList As New List(Of Array)()
Dim newline() As String
Dim CurrentAccountName As String
Dim CurrentAccount As Account
Dim AccountNameExsists As Boolean
Dim NewAccount As Account
Dim NewEntry As Entrey
Dim WrongFileErrorTrigger As String
ListOfLoadedAccountNames.Clear()
'opens the file
Try
Dim sr As New IO.StreamReader(File1Loc)
Console.WriteLine("Loading full report please waite")
MsgBox("Loading full report may take a while.")
'While we have not finished reading the file
While (Not sr.EndOfStream)
'spliting eatch line up into an array
newline = sr.ReadLine.Split(","c)
'storring eatch array into a list
RawEntList.Add(newline)
End While
然后我当然会遍历列表以提取信息来填充对象,如下所示:
For Each Entr In RawEntList
CurrentAccountName = Entr(36)
AccountNameExsists = False
For Each AccountName In ListOfLoadedAccountNames
If CurrentAccountName = AccountName Then
AccountNameExsists = True
End If
Next
【问题讨论】:
标签: vb.net replace trim streamreader