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

Threaded View

  1. #8
    Join Date
    Mar 2012
    Posts
    14

    Re: Need Help with Parser C#

    Quote Originally Posted by Peter_B View Post
    To (mis)quote the late, great Eric Morecambe, "you are using all the right code, but not necessarily in the right order"

    When the user clicks the button, your code is prompting the user for the dictionary file, reading it in (in the while loop) and (also in the while loop) checking in the dictionary. If you do want to read the file on each button click, it would be simpler just to check each line in turn against the text box. No need for a dictionary at all.

    But, the better design would be this (IMHO ):
    1) Read the file in when the dialog first opens, and set up the dictionary. This dictionary will need to be stored in the form so it can be accessed by the click handler.
    2) Let the user type what they want in the text box
    3) When the user clicks the button, check for this text in the dictionary, and set the output box appropriately.

    You could also have another button which would prompt for a new file when clicked, and recreate the dictionary based on this file.
    That is what I'm aiming for I guess I sound pretty much all over the place but I really don't know how to sort out the code. I don't know which parts to split up to allow the dictionary to be stored in the form.

    EDIT: for example how would I put the click handler for the open dialog into this
    Code:
    private void Form1_Load(object sender, EventArgs e)
            {
    
            }
    If I could understand how to do that so the dictionary is stored in there, then I guess it would allow me to use the dictionary for the inputBx and outputBx with a click handler for the output
    Last edited by dahrull; March 18th, 2012 at 11:02 AM.

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

Featured