我已经构建了一个项目,从报表中读取数据,它用于正常工作,但现在出于某种原因,报告把每件事情都放到字符串中。所以我想修改我的流阅读器来删除或忽略引号,因为它读取行。VB.net如何从一个streamReader.readline.split()
这是读取行的部分snipet。
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
它不是一个字符串,它是一个字符串数组,它是split()如何工作的。你不能在数组上调用replace。 我想我可以在数组中调用它,就像这个'ent(0).Replace(Char(34),“”)''那样,这个数值就必须通过50次。女巫已经在运行150,000次或更多次的另一个血液中跑步。它是可移动的,但它是非常无效的。所以,这种排除你的前两个解决方案,但第三个我可能会尝试看看它是否有效。 – skyzzle
@SkylineGodzilla:在调用'.Split()'之前,先放上'.Replace()'。而后者可能会返回一个数组,而'ReadLine()'不会:'sr.ReadLine()。Replace(Chr(34),“”).Split(“,”c)'。 –
@WallyModz:OR'StringName.Replace(“”“”c,“”)''。 ;) –