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