Results 1 to 4 of 4

Thread: [2005] Parsing a textfile by Delimiters of Capital Words.

Threaded View

  1. #2
    Frenzied Member stimbo's Avatar
    Join Date
    Jun 2006
    Location
    UK
    Posts
    1,739

    Re: [2005] Parsing a textfile by Delimiters of Capital Words.

    I'm not sure I understood all that so this is probably not right. I simply went by the rule that: IF the first word of the current sentence is totally in capital letters, then that entire sentence would be wanted for the final collection. So from the list you posted at the end, this would be in a collection you could output:

    DOBERMAN A BIG handsome
    ENGLISH Bulldog pups for sale
    ENGLISH Bulldog pups, vet 4,

    Place a listbox on the form and place this code in a button click event or something.

    2 Code:
    1. Dim finalWords As New List(Of String)
    2.  
    3.         Using SR As New IO.StreamReader("star.txt")
    4.             Dim tempStr As String = Nothing
    5.             Dim temp() As String
    6.             Dim isUpp As Boolean
    7.  
    8.             Do While SR.Peek <> -1
    9.                 tempStr = SR.ReadLine.Trim
    10.                 temp = Nothing
    11.                 temp = tempStr.Split(" "c)
    12.  
    13.                 isUpp = True
    14.  
    15.                 For Each ch As Char In temp(0).Trim
    16.                     If Not Char.IsUpper(ch) Then
    17.                         isUpp = False
    18.                     End If
    19.                 Next
    20.  
    21.                 If isUpp = True Then
    22.                     finalWords.Add(tempStr)
    23.                 End If
    24.             Loop
    25.         End Using
    26.  
    27. Me.ListBox1.Items.AddRange(finalWords.ToArray)
    Last edited by stimbo; May 22nd, 2007 at 02:27 PM. Reason: clarfying routine
    Stim

    Free VB.NET Book Chapter
    Visual Basic 2005 Cookbook Sample Chapter

Posting Permissions

  • You may not post new threads
  • You may not post replies
  • You may not post attachments
  • You may not edit your posts
  •  



Click Here to Expand Forum to Full Width