Thread: why i cann't access the index of txtContent?

  1. #1
    Registered User
    Join Date
    May 2016
    Posts
    4

    why i cann't access the index of txtContent?

    Code:
       private void SearchText(string searchText)  // search phrase or text in txtcontent of notepad        {
                for (int i = 0; i < txtContent.TextLength; i++)
                {
                    for (int j = 0; j < searchText.Length; j++)
                    {
                        if (txtContent[i] == searchText[j])  // why i cann't access txtcontent index?
                            txtContent.Select(_startIndex, searchText.Length);
    
    
                    }
    
    
                }
    
    
            }

  2. #2
    Gawking at stupidity
    Join Date
    Jul 2004
    Location
    Oregon, USA
    Posts
    3,218
    What? What types are you dealing with? You need to give more detail.
    If you understand what you're doing, you're not learning anything.

  3. #3
    Lurking whiteflags's Avatar
    Join Date
    Apr 2006
    Location
    United States
    Posts
    9,616
    I agree with itsme86. The type of txtContent needs to be said, but it's pretty obvious the trouble is txtContent isn't a string type variable; otherwise, it would work.

  4. #4
    Registered User
    Join Date
    May 2016
    Posts
    4

    what is wrong how can i correct my problem? please help me

    Code:
       private void SearchText(string searchText)        {
                for (int i = 0; i < txtContent.Text.Length; i++)
                {
    
    
                    for (int j = 0; j < searchText.Length; j++)
                    {
                        if (txtContent.Text[i] == searchText[j])
                        {
                            _startIndex += 1;  // default value of _startindex i made -1;
                            txtContent.Select(_startIndex, searchText.Length);
                        }
                        else
                        {
                            _startIndex = -1;
                            MessageBox.Show("phrase wasn't found");
    
    
                        }
                    }
    
    
                }
    
    
            }
    Last edited by badger77; 05-22-2016 at 08:58 AM.

Popular pages Recent additions subscribe to a feed

Similar Threads

  1. Can not copy a string from index to index?
    By heatblazer in forum C Programming
    Replies: 7
    Last Post: 01-07-2016, 05:51 PM
  2. Replies: 8
    Last Post: 04-04-2012, 09:03 PM
  3. Replies: 1
    Last Post: 08-12-2011, 03:07 AM
  4. short index vs. int index
    By ardavirus in forum C Programming
    Replies: 3
    Last Post: 06-13-2011, 05:09 AM
  5. i cann`t understand this code
    By Meshal in forum C Programming
    Replies: 1
    Last Post: 01-23-2007, 06:21 AM

Tags for this Thread