0

テキスト ファイルからレコードを取得して配列に分割するのに問題があります。

すべてのレコードは次の形式です。

  --------------------------- CITATION   01 OF   99 -------------------------
Authors:  Oliver, Ron
Oliver, Helen
Title:  Information Access and Retrieval with Hypermedia Information Systems. /
 by Oliver, Ron; Oliver, Helen
Pub.Date:  1996
Document no.:  EJ520272
FOUND IN:  British Journal of Educational Technology; v27 n1 p33-44 Jan 1996
Abstract:  Describes an investigation of the search strategies employed by
 novice users of an interactive information system. A class of 12-year-old
 students was instructed in use of an electronic encyclopedia, which they used
 as an information source for projects and to complete skills tests. Students
 employed inefficient search strategies and had difficulty creating search
 requests for information-related problems. (Author/JKP)
Pub.Type:  Research/technical(143); Journal article(080)
Language:  English
RIE/CIJE issue:  CIJJUL96
If not avail. in your library or through ILL, for sale from:  UMI
Minor Identifiers:  Electronic Media
Major Descriptors:  Hypermedia
Information Retrieval
Online Searching
Optical Data Disks
Search Strategies
Minor Descriptors:  Access to Information
Elementary Education
Encyclopedias
Information Sources
Problems
ISSN:  0007-1013
  --------------------------- CITATION   02 OF   99 -------------------------
Authors:  Kimmel, Stacey
Title:  Robot-Generated Databases on the World Wide Web. / by Kimmel, Stacey
Pub.Date:  1996
Document no.:  EJ520165
FOUND IN:  Database; v19 n1 p40-43,46-49 Feb-Mar 1996
Abstract:  Provides an overview of robots that retrieve World Wide Web documents
 and index data and then store it in a database. Nine robot-generated databases
 are described, including record content, services, search features, and sample
 search results; and sidebars discuss the controversy about Web robots and other
 resource discovery tools. (LRW)
Pub.Type:  Descriptive(141); Journal article(080)
Language:  English
RIE/CIJE issue:  CIJJUL96
If not avail. in your library or through ILL, for sale from:  UMI
Major Identifiers:  World Wide Web
Minor Identifiers:  Examples
Major Descriptors:  Databases
Information Retrieval
Online Searching
Robotics
Minor Descriptors:  Comparative Analysis
Indexing
Problems
Search Strategies
ISSN:  0162-4105

And so on....

次の情報のみが必要です: テキスト ファイル内の各レコードの著者、タイトル、FOUND IN、および要約。これをどのように行うのですか?

私のコード:

Public Class Form1

    Private Sub btnImport_Click(ByVal sender As System.Object, ByVal e As System.EventArgs) Handles btnImport.Click

        Dim fd As New OpenFileDialog()
        fd.Title = "Please select a txt file"
        fd.InitialDirectory = Application.StartupPath & "\inc"
        fd.Filter = "Text Documents (*.txt)|*.txt"
        fd.Multiselect = False
        fd.RestoreDirectory = True
        Dim strFileName As String

        If (fd.ShowDialog() = DialogResult.OK) Then
            strFileName = fd.FileName
            Dim sr As System.IO.StreamReader = System.IO.File.OpenText(strFileName)


            Dim recs As String = sr.ReadToEnd
            ''Dim rec() As String = recs.Split(" ")

            sr.Close()

            txtAbstract.Text = recs(0)

        End If
    End Sub

End Class

Microsoft Visual Studio 2010 Express を使用しています。前もって感謝します。

4

2 に答える 2

0

sr.ReadToEnd を実行しないでください。行ごとに読むと、これは簡単になります(より簡単になります)。

Using sr As IO.StreamReader = fi.OpenText
    Do While sr.Peek > -1
        sLine = sr.ReadLine
        'Your code to parse the line or read the data here
    Loop
End Using
于 2013-09-18T22:54:28.570 に答える