1. This site uses cookies. By continuing to use this site, you are agreeing to our use of cookies. Learn More.

Regex in listbox?

Discussion in 'Visual Basic .NET' started by istuff, Sep 25, 2009.

  1. istuff

    istuff Junior Member

    Joined:
    Mar 2, 2009
    Messages:
    138
    Likes Received:
    47
    Occupation:
    Cookie Stuffing
    Location:
    Toronto
    hey can some one tell me how to apply regex to items in listbox?

    I have been having problems, converting them to string. and listbox1.item.tostring() doesnt help...

    anyone have a tutorial of i can parse listbox items directly or indirectly (importhing them a in a textbox or something)?

    thanks
     
  2. graham23s

    graham23s BANNED BANNED

    Joined:
    Jul 26, 2008
    Messages:
    154
    Likes Received:
    106
    Hi Buddy,

    Would you not want to apply the regex before the string is in the listbox? or even once you select a listbox item?

    cheers

    Graham
     
  3. hotcheats

    hotcheats Regular Member

    Joined:
    Dec 2, 2008
    Messages:
    328
    Likes Received:
    74
    Location:
    EU
    This is easy - if you want to eg. put items from Listbox to Textbox

    Code:
    For Each item As String In Listbox1.Items 
    TextBox1.Text =  Textbox1.Text & item & Environment.NewLine
    Next
    
    And you can do regex too - just create another variable "item2" and do regex on "item" from the For Each loop and attribute it to the "item2" and then replace all the items in Listbox with the Regex-ed ones. Easy peasy.
     
  4. istuff

    istuff Junior Member

    Joined:
    Mar 2, 2009
    Messages:
    138
    Likes Received:
    47
    Occupation:
    Cookie Stuffing
    Location:
    Toronto
    thanks I figured this one out, by applying regex to textbox then put them into listbox