Results 1 to 5 of 5

Thread: Running Total for searched strings

  1. #1

    Thread Starter
    New Member
    Join Date
    May 2012
    Posts
    4

    Running Total for searched strings

    Had this issue I was wondering about. This is what it actually DOES then Ill say what I want it to DO. It grabs the word from a notepad I have saved in the directory, and brings it forward onto a form in designated area's and after whomever is done with the word and definition. It'll tell you how many times it's been looked up. Problem is the count applies NOT to the individual words as I'd have liked but EVERY word that has been searched for in the session.: Here's a snip-it
    Code:
     try
                        {
                            WordList = Word.Split('_');
                            WordListCount = Word.Split('_');
    
                            if (WordFound == true)
                            {
                                MessageBox.Show("The word " + WordList[0] + " means" + WordList[1] + WordList[2]);
                                for (Clicks = 0; Clicks < 1; Clicks++)
                                {
                                    ClickCount = ClickCount + 1;
                                }
                                MessageBox.Show("The word " + WordList[0] + " has been searched for " + ClickCount + " time(s)");
                            }
                        }
    I would greatly appreciate any insight as to how to get the count to apply for each word individually. Either just within the session or, if possible, keep a constant running total of searched words.

  2. #2
    eXtreme Programmer .paul.'s Avatar
    Join Date
    May 2007
    Location
    Chelmsford UK
    Posts
    26,422

    Re: Running Total for searched strings

    this is the vb.net forum. is this a C question?
    vbforums has dedicated C forums

  3. #3
    eXtreme Programmer .paul.'s Avatar
    Join Date
    May 2007
    Location
    Chelmsford UK
    Posts
    26,422

    Re: Running Total for searched strings


  4. #4

    Thread Starter
    New Member
    Join Date
    May 2012
    Posts
    4

    Re: Running Total for searched strings

    Yes it's from Visual Studio, specifically C#.

  5. #5
    Frenzied Member MattP's Avatar
    Join Date
    Dec 2008
    Location
    WY
    Posts
    1,227

    Re: Running Total for searched strings

    Quote Originally Posted by Redwit View Post
    Yes it's from Visual Studio, specifically C#.
    Whoosh....

    -----

    What are you using WordListCount for?

    The line ClickCount = ClickCount + 1; looks like where you're trying to figure out how many times a word has been searched but the problem is the word isn't associate with this variable anywhere so you just get a running count of all searched words.

    I would recommend you take a look at Dictionary<string, int> where you use the word as the key and click count as the value.
    This pattern in common to all great programmers I know: they're not experts in something as much as experts in becoming experts in something.

    The best programming advice I ever got was to spend my entire career becoming educable. And I suggest you do the same.

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