English 中文(简体)
我怎么能够把这一文本存档在VB。 NET?
原标题:How can I parse this text file in VB.NET?

Example Data Link - Sorry, ben t Format dateded.

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
最佳回答

你一度阅读了文本,我想到文件。 阅读能力将是好的选择。

 Dim str
 Dim fileName = "C:SampleData.txt"

 Dim lines() = File.ReadAllLines(fileName)

 For i = 0 To lines.GetUpperBound(0) Step 7
  str = String.Format("{0}{1}{2}{3}{4}{5}", 
                     lines(i), lines(i + 1), lines(i + 2), lines(i + 3), 
                     lines(i + 4), lines(i + 5))
  Console.WriteLine(str)
 Next
问题回答

暂无回答




相关问题
Is Shared ReadOnly lazyloaded?

I was wondering when I write Shared ReadOnly Variable As DataType = New DataType() Or alternatively Shared ReadOnly Variable As New DataType() Is it lazy loaded or as the instance initializes? ...

Entertaining a baby with VB.NET

I would like to write a little application in VB.NET that will detect a baby s cry. How would I get started with such an application?

Choose Enter Rather than Pressing Ok button

I have many fields in the page and the last field is a dropdown with list of values. When I select an item in a dropdown and press Enter, it doesn t do the "Ok". Instead I have to manually click on Ok ...

ALT Key Shortcuts Hidden

I am using VS2008 and creating forms. By default, the underscore of the character in a textbox when using an ampersand is not shown when I run the application. ex. "&Goto Here" is not ...

Set Select command in code

On button Click I want to Set the Select command of a Gridview. I do this and then databind the grid but it doesn t work. What am i doing wrong? protected void bttnView_Click(object sender, ...

Hover tooltip on specific words in rich text box?

I m trying to create something like a tooltip suddenly hoovering over the mouse pointer when specific words in the richt text box is hovered over. How can this be done?

热门标签