Page 3 of 3 FirstFirst 123
Results 81 to 82 of 82

Thread: Adding a dictionary instead of a list

  1. #81

    Thread Starter
    Lively Member
    Join Date
    Nov 2015
    Posts
    114

    Re: Adding a dictionary instead of a list

    Code:
    1. CheckWordFromTheDictionaryFunction()
    2. MoveNextFunction ()

    Step .1
    OnButtonClick_Event

    Code:
    3.1. Raise the event that will trigger the CheckWordFromTheDictionaryFunction.
    Step. 1.A.
    Duties: - CheckWordFromTheDictionaryFunction
    Code:
    1. To strickly check if the currentword is in the dictionary or not. But it should not move next!
    Instructions:

    Code:
    (1.) To check if the RichTextBox is Not Null, 
    if it is Null, quit. MessageBox.Show("You have no words to check!")
    (2.) ElseIf Not Null, 
    	(A.) Check if the Currentword is in the dictionary
    If the Currentword is found, 
    	(B.) take the words from the second column, and store them into a CurrentSuggestions Variable.
    ElseIf the Currentword from the RichtextBox is not found, call the MoveNextFunction to move to the NextwordIndex.
    Step .1 .B
    Duties:- MoveNextFunction

    Code:
    1. To strickly move to the NextwordIndex without doing anything else!
    Instructions
    Code:
    1.1  The MoveNextFunction will move to the NextwordIndex of the RichTextBox, and then call the CheckWordFromTheDictionaryFunction.
    	1.3. If the CheckWordFromTheDictionaryFunction does not find the Currentword that has been moved to, it will call the MoveNextFunction to move to the NextwordIndex.
    Step. 2
    Code:

    Code:
    If the Currentword was found. 
    	2.1. Highlight the Currentword to be replaced.
    Clear the ContextMenuStrip.Clear() because of repetitive tasks, and
    	2.2. Load the items from the CurrentSuggestions variable into the ContextMenuStrip.
    Step. 3
    Code:
    3.2. If no Currentword was found from the dictionary in the whole document by the CheckWordFromTheDictionaryFunction after the MoveNextFunction was called.
    	A messageBox.Show() function will be shown with("No Matches were found from the dictionary in the whole document!"). 
    	When the user clicks the OK button of the MessageBox.Show()
    The CheckWordFromTheDictionaryFunction should be stopped without closing the whole program. Otherwise, there is already a Me.Close() function on the BtnClose Button.
    Hence, here the program is ideal.

    Step .4
    Code:
    If Currentword was found, display the ContextMenuStrip, and allow the user to select what he or she wants.
    ElseIf the Currentword was not good. The MoveNextFunction will be called.
    ElseIf the CurrentSuggestions are good. Replace the Currentword with CurrentSelectedSuggestion Item from the contextMenuStrip.
    Step. 5
    Code:

    Code:
    It will now wait for the User to click the button again for the CheckWordFromTheDictionaryFunction to be called. We have agreed that the CheckWordFromTheDictionaryFunction is to check the Currentword from where it has been moved to! 
    ElseIf all the replacements have been made, MessageBox.Show("The task is Completed."). End.
    Terminologies

    Code:
    1. The CheckWordFromTheDictionaryFunction is the function to do the checking.
    2. The MoveNextFunction is in charge of moving to the NextwordIndex.

    Keywords to be used in the program:
    Code:
    Currentword, CurrentSuggestions Variable, NextwordIndex, CurrentSuggestions, CurrentSelectedSuggestion Item
    Items to be created:
    Code:
    Button for search, Button for Close, ContextMenuStrip1, RichTextBox1, Connection to a Dictionary path.
    Functions to be created
    Code:
    1. CheckWordFromTheDictionaryFunction
    2. MoveNextFunction
    Last edited by nqioweryuadfge; Dec 23rd, 2015 at 08:36 AM.

  2. #82
    Super Moderator FunkyDexter's Avatar
    Join Date
    Apr 2005
    Location
    An obscure body in the SK system. The inhabitants call it Earth
    Posts
    7,957

    Re: Adding a dictionary instead of a list

    Now that's what I call a well understood algorithm. I know it probably felt a bit laborious to get to this point but, believe me, it was necessary and I hope it hasn't put you off programming. As you get more experienced you can probably start skipping a lot of this forward planning and jump straight into code but when you're just starting out it's hugely valuable.

    Now you want to start writing code. Create your form, buttons, text boxes etc. (or just reuse the ones you already have) and start turning those steps into code. Add an event to the search button, call the move next function (or possibly call a similar CallFirst if you want to keep them separate) and call the CheckForWord function if you haven't reached the end of the text box. Then write the code for MoveNext and CheckForWord based on the steps you've detailed above.

    I'd advise you to do this in small, testable steps instead of trying to do the whole thing at once, it just makes things easier. So first of all get MoveNext working and make sure you can select each word in turn. Once you've done that get checkForWord working and make sure you can pop up an appropriate context menu on each word. Finally, handle the user selecting a word and replacing the text in the rich text box with their selection.

    Your previous posts contained all the bits of syntax your need (just in the wrong order) so you might well be able to finish off yourself but if you do get stuck (you probably will, we all do) then post back with your code. Now that you understand the algorithm thoroughly and so do we it'll be MUCH easier to get you past any bumps.
    The best argument against democracy is a five minute conversation with the average voter - Winston Churchill

    Hadoop actually sounds more like the way they greet each other in Yorkshire - Inferrd

Page 3 of 3 FirstFirst 123

Tags for this Thread

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