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

Thread: validation

  1. #1
    Join Date
    Jan 2012
    Posts
    0

    validation

    I have a text file containing text in the form,

    all the world ends in 10 days 2
    sample line1
    sample line 2
    roger federer wins the tournament 3
    sample line 1
    sample line 2
    sample line 3


    In the about example, there are two types of lines,
    1. starts without blank space
    2. starts with blank space

    all the world ends in 10 days 2
    the last digit, i.e 2 should be extracted from each line which starts without a blank space (expedtedNoOfLines)
    the number of lines which starts with a blank space should match expedtedNoOfLines

    while((line = sr.ReadLine()) !=null)
    {
    if(!line.startswith(" "))
    {
    expectedLines = line.Substring(line.Length-1, 1);
    }
    else
    {
    actualLinesCount++;
    }

    if(expectedLines != actualLinesCount)
    richTextEditor.SelectionColor = Color.Red;
    else
    richTextEditor.SelectionColor = Color.Black;

    richTextEditor.text = line;
    richTextEditor.text = System.Environment.NewLine;
    }

    The above code is not working.....any help?

  2. #2
    Join Date
    Jul 2007
    Location
    Illinois
    Posts
    517

    Re: validation

    You seem to be assigning Environment.Newline to the rich text box control right after you assign the line to it:

    Code:
    richTextEditor.text = line;
    richTextEditor.text = System.Environment.NewLine;
    Not sure if this is intentional, probably not. What you're probably looking for is:

    Code:
    richTextEditor.text = line;
    richTextEditor.text += System.Environment.NewLine;
    or just

    Code:
    richTextEditor.text = (line + System.Environment.NewLine);
    R.I.P. 3.5" Floppy Drives
    "I know not with what weapons World War III will be fought, but World War IV will be fought with sticks and stones." - Albert Einstein

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