2016-11-21 7 views
0

私はテキストファイルを読み込み、データテーブルに配置しようとしています。ファイルには、以下のようになります。vb.netテキストファイルReadLine

Control 1 
- 1 Next line 
- 1 Next Line 
    1 Same line 

Control 2 
- 2 Next line 
- 2 Next Line 
    2 Same line 

私は以下のようなデータを構造化したい:

Title | Data 
Control1, - 1 Next line - 1 Next line 1 Same line 
Control2, - 2 Next line - 2 Next line 2 Same line 


    Do 
       Dim strInputFileLine As String = srReader.ReadLine() 
       If strInputFileLine Is Nothing Then Exit Do 


       If strInputFileLine.Contains("Control 1") Then 
        'How Do I get the Text before Control 2 Begins??? 


       End If 
loop 

答えて

0

あなたはこの

Dim strInputFileLine As String 
Dim nextLine,text As String 
text = "" 
     Do 
      strInputFileLine = srReader.ReadLine() 
      If strInputFileLine Is Nothing Then Exit Do 


      If strInputFileLine.Contains("Control 1") Then 
       Do 
        nextLine = srReader.Readline() 
        If nextLine = "Control 2" Then Exit Do 'you can even use .Contains 
        Else 
         text += nextLine 
       loop 
      End If 
     loop 
+0

が合意試すことができます - 私は尋ねた後、私はそのことを考えて。ありがとうございました。 –

関連する問題