dcsimg
CodeGuru Home VC++ / MFC / C++ .NET / C# Visual Basic VB Forums Developer.com
Results 1 to 5 of 5

Thread: counting occurenece of each word in a large text file

  1. #1
    Join Date
    Oct 2011
    Location
    Malaysia , Selangor
    Posts
    89

    counting occurenece of each word in a large text file

    hi all , I'm using regex object to count occurrence of each word in a text file with (44644 words ). i put all words in Matches , then put them in a list box , and i find the number of occurrences for each word using another list box with listview . the program is work well with a small text file , but the problem when i use the text file with (44644 words). the words can be list in the box but the occurrence of each word doesn't show in listview . please can any help how solve this problem .

  2. #2
    Join Date
    Sep 2001
    Location
    Québec, Canada
    Posts
    1,923

    Re: counting occurenece of each word in a large text file

    Post your code please, it will help us.

    JeffB
    CodeGuru VB FAQ Visual Basic Frequently Asked Questions
    VB Code color Tool to color your VB code on CodeGuru
    Before you post Importants informations to know before posting

  3. #3
    Join Date
    Oct 2011
    Location
    Malaysia , Selangor
    Posts
    89

    Re: counting occurenece of each word in a large text file

    ok , sure ... but please help with my problem , the following program work with small text file but when i use it with large text file the result don't show on the listview
    assume the lisbox1 contain (44644)items

    Code:
    Public Function countoccurences()
    Dim i, j
    Dim lst As ListItem
    
      For i = 0 To List1.ListCount - 1
        For j = 0 To List2.ListCount - 1
          If List1.List(i) = List2.List(j) Then
            List2.ItemData(j) = List2.ItemData(j) + 1
            Exit For
          End If
        Next j
        If j = List2.ListCount Then
          List2.AddItem List1.List(i)
          List2.ItemData(List2.NewIndex) = 1
        End If
      Next i
      For j = 0 To List2.ListCount - 1 Step 1
    Set lst = ListView1.ListItems.Add(, , List2.List(j))
      lst.ListSubItems.Add , , List2.ItemData(j)
      Next j
    End Function
    Private Sub Form_Load()
    ListView1.ColumnHeaders.Add , , "Word"
    ListView1.ColumnHeaders.Add , , "Frequency"
    
    End Sub
    Last edited by falahjomor; November 12th, 2011 at 11:55 AM.

  4. #4
    Join Date
    Jan 2006
    Location
    Fox Lake, IL
    Posts
    15,007

    Re: counting occurenece of each word in a large text file

    Listbox can only hold 32K items! Nobody reads more than 10 or so items, so, I'd re-think that part
    David

    CodeGuru Article: Bound Controls are Evil-VB6
    2013 Samples: MS CODE Samples

    CodeGuru Reviewer
    2006 Dell CSP
    2006, 2007 & 2008 MVP Visual Basic
    If your question has been answered satisfactorily, and it has been helpful, then, please, Rate this Post!

  5. #5
    Join Date
    Oct 2011
    Location
    Malaysia , Selangor
    Posts
    89

    Re: counting occurenece of each word in a large text file

    then how can i deal with this matter , i spent 1 month just to find a solution but i haven't find ... please help

Posting Permissions

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


Windows Mobile Development Center


Click Here to Expand Forum to Full Width




On-Demand Webinars (sponsored)