0
Example Data Link - 抱歉,粘贴时无法正确格式化。如何在VB.NET中解析这个文本文件?
1.
Dec 01, 2011
06:00:00 AM
Dec 01, 2011
07:05:00 AM
65
2.11
2.
Dec 01, 2011
06:00:00 PM
Dec 01, 2011
07:05:00 PM
65
2.11
3.
Dec 02, 2011
06:05:00 AM
Dec 02, 2011
07:05:00 AM
60
1.95
我想每个单独行有自己的一席之地阵列中的数据表或,但我似乎无法得到它的正常工作。结尾字符必须有不同的东西吗?
代码如下。
Dim strOutput As String = ""
'' Demo Data
'Dim strData As String = "59. Dec 01, 2011 06:05:00 PM Dec 01, 2011 10:05:00 PM 240 80.00"
'strOutput = +FormatRow(strData)
'' Demo Data
Dim sFileName As String = OpenFileDialog.FileName
If My.Computer.FileSystem.FileExists(sFileName) Then
Dim srFileReader As System.IO.StreamReader
Dim sInputLine As String
srFileReader = System.IO.File.OpenText(sFileName)
sInputLine = srFileReader.ReadLine()
Do Until sInputLine Is Nothing
'strOutput = +FormatRow(sInputLine)
Dim title As String = srFileReader.ReadLine()
Dim startTime As DateTime = srFileReader.ReadLine() & " " & srFileReader.ReadLine()
Dim endTime As DateTime = srFileReader.ReadLine() & " " & srFileReader.ReadLine()
Dim timeSpan As TimeSpan = endTime.Subtract(startTime)
Dim minutesTotal As Integer = timeSpan.TotalMinutes
' Burn Minutes
srFileReader.ReadLine()
Dim billMinutes As Integer = minutesTotal
Dim billTotal As Double = srFileReader.ReadLine()
strOutput += ""
Loop
输出像
12/1/2011 6:00:00 AM 12/1/2011 7:05:00 AM 65 65 2.11
请格式化该数据文件内容并将其添加到您的文章。 – adatapost 2012-01-13 03:42:10
你是什么意思格式化它?当我复制并粘贴它时,stackoverflow将更改格式。我会尝试粘贴一些,它只是一个纯文本文件。 – Landmine 2012-01-13 03:44:39
输出格式是什么? – 2012-01-13 03:44:48