Click here to Skip to main content
Rate this: bad
good
Please Sign up or sign in to vote.
See more: find
Hello .
 
i want to find a word in the textbox
 
i want if the word was between two <> then , the result are displayed in a listbox
 
Thanks
 
OP's additional information moved from non-solution below
Excuse me, i am work with vb.net
please help me , very necessary
Posted 12-Nov-12 4:18am
Edited 12-Nov-12 5:27am
Nelek63K
v2
Comments
richcb at 12-Nov-12 9:42am
   
What language? What have you tried?

1 solution

Rate this: bad
good
Please Sign up or sign in to vote.

Solution 1

Hi there,
 
This is something to get you started on if you wanted to trim out multiple words.
 
Hopefully this will give you something to start with.
 
UPDATED WITH VB
 

''' <summary>
 ''' Gets the list items.
 ''' </summary>
 ''' <param name="p_textToSearch">The text to search.</param>
 Public Sub GetListItems(ByVal p_textToSearch As String)
     'listBox1 is the listbox you want to populate
     Dim items As New ListBox.ObjectCollection(listBox1)
     If (p_textToSearch.Contains("<")) AndAlso (p_textToSearch.Contains(">")) Then
         Dim wordsStrings As String() = p_textToSearch.Split(">"c)
         For Each wordsString As String In wordsStrings
             Dim firstIndexOfBracket As Integer = wordsString.IndexOf("<", StringComparison.Ordinal)
 
             If firstIndexOfBracket < 0 Then
                 firstIndexOfBracket = 0
             End If
             Dim preTrim As String = wordsString.Substring(firstIndexOfBracket)
             Dim altered As String = preTrim.Replace("<", "")
 
             items.Add(altered.Trim())
         Next
 
     End If
     listBox1.Refresh()
 End Sub
 

 

   /// <summary>
   /// Gets the list items.
   /// </summary>
   /// <param name="p_textToSearch">The text to search.</param>
   public void GetListItems(string p_textToSearch)
   {
       //listBox1 is the listbox you want to populate
       ListBox.ObjectCollection items = new ListBox.ObjectCollection(listBox1);
       if ((p_textToSearch.Contains("<")) && (p_textToSearch.Contains(">")))
       {
           string[] wordsStrings = p_textToSearch.Split('>');
           foreach (var wordsString in wordsStrings)
           {
               int firstIndexOfBracket = wordsString.IndexOf("<", StringComparison.Ordinal);
              
               if (firstIndexOfBracket < 0)
               { 
                firstIndexOfBracket = 0; 
               }
               string preTrim = wordsString.Substring(firstIndexOfBracket);
               string altered = preTrim.Replace("<", "");
 
               items.Add(altered.Trim());
           }
       }
       listBox1.Refresh();
   }
  Permalink  
v3

This content, along with any associated source code and files, is licensed under The Code Project Open License (CPOL)

  Print Answers RSS
0 OriginalGriff 5,170
1 DamithSL 4,357
2 Maciej Los 3,750
3 Kornfeld Eliyahu Peter 3,470
4 Sergey Alexandrovich Kryukov 2,851


Advertise | Privacy | Mobile
Web03 | 2.8.141216.1 | Last Updated 13 Nov 2012
Copyright © CodeProject, 1999-2014
All Rights Reserved. Terms of Service
Layout: fixed | fluid

CodeProject, 503-250 Ferrand Drive Toronto Ontario, M3C 3G8 Canada +1 416-849-8900 x 100