我一直在尝试创建一个正在创建的迷宫游戏排行榜,并使用CSV文件存储我的数据。我每行有两个字段,类似于詹姆斯20岁卢克(34岁)分别是“玩家名”和“得分”。
[每当我运行下面的代码时,都会显示我的列表框;
詹姆斯
20
卢克
34
我正在尝试将其显示为诸如
詹姆斯20
路加福音34
我已经尝试将第一个字段存储为字符串,并抓住下一个字段并将其串联在一起以将其显示在一行上,但是我无法抓住下一个字段,因为这将导致读数的重新编码功能。
FileIO.TextFieldParser(
"C:\Users\zamks1622\Desktop\Computing\SAT\Leaderboard.csv")
MyReader.TextFieldType = FileIO.FieldType.Delimited
MyReader.SetDelimiters(",")
Dim currentRow As String()
While Not MyReader.EndOfData
Try
currentRow = MyReader.ReadFields()
Dim currentField As String
For Each currentField In currentRow
ListLeaderboard.Items.Add(currentField)
Next
Catch ex As Microsoft.VisualBasic.
FileIO.MalformedLineException
MsgBox("Line " & ex.Message &
"is not valid and will be skipped.")
End Try
End While
End Using
我认为这可能有帮助
Try
currentRow = MyReader.ReadFields()
ListLeaderboard.Items.Add(Join(currentRow , " "))
Catch ex As Microsoft.VisualBasic.FileIO.MalformedLineException