Results 1 to 9 of 9

Thread: [RESOLVED] Removing Specific text in a listbox

  1. #1

    Thread Starter
    Addicted Member
    Join Date
    Jan 2006
    Posts
    219

    Resolved [RESOLVED] Removing Specific text in a listbox

    ok say i have 3 things loaded in a listbox it looks like this
    hi!
    hi1!
    hi2!
    how can i remove the "!" but i would also like for it to be an option so like if i put $ in a textbox it will remove all of "$" I would appreciate the help thank you!

  2. #2
    Software Carpenter dee-u's Avatar
    Join Date
    Feb 2005
    Location
    Pinas
    Posts
    11,127

    Re: Removing Specific text in a listbox

    You may have to loop through the contents of the listbox then use the REPLACE function...
    Regards,


    As a gesture of gratitude please consider rating helpful posts. c",)

    Some stuffs: Mouse Hotkey | Compress file using SQL Server! | WPF - Rounded Combobox | WPF - Notify Icon and Balloon | NetVerser - a WPF chatting system

  3. #3
    Frenzied Member d3gerald's Avatar
    Join Date
    Jan 2006
    Posts
    1,348

    Re: Removing Specific text in a listbox

    i think this requires a nested for loop
    On error goto Trap

    Trap:
    in case of emergency, drop the case...

    ****************************************
    If this post has been resolved. Please mark it as "Resolved" by going through the "Thread Tools" above and clicking on the "Mark Thread Resolved " option.
    if a post is helpful to you, Please Rate it by clicking on the Rate link right below the avatar

  4. #4

    Thread Starter
    Addicted Member
    Join Date
    Jan 2006
    Posts
    219

    Re: Removing Specific text in a listbox

    well i have very little experience in vb so could you guess give me some examples?

  5. #5
    Software Carpenter dee-u's Avatar
    Join Date
    Feb 2005
    Location
    Pinas
    Posts
    11,127

    Re: Removing Specific text in a listbox

    Something like...

    VB Code:
    1. Private Sub Command1_Click()
    2.     RemoveCharacter "!"
    3. End Sub
    4.  
    5. Private Sub RemoveCharacter(ByVal strChar As String)
    6.     Dim a As Long
    7.     For a = 0 To List1.ListCount - 1
    8.         List1.List(a) = Replace$(List1.List(a), strChar, "")
    9.     Next
    10. End Sub
    Regards,


    As a gesture of gratitude please consider rating helpful posts. c",)

    Some stuffs: Mouse Hotkey | Compress file using SQL Server! | WPF - Rounded Combobox | WPF - Notify Icon and Balloon | NetVerser - a WPF chatting system

  6. #6

    Thread Starter
    Addicted Member
    Join Date
    Jan 2006
    Posts
    219

    Re: Removing Specific text in a listbox

    how could i make it so whatever i put in a text box it removes?

  7. #7
    Frenzied Member d3gerald's Avatar
    Join Date
    Jan 2006
    Posts
    1,348

    Re: Removing Specific text in a listbox

    call dee-u's function in the change event of your textbox

    VB Code:
    1. Private Sub Text1_Change()
    2.     RemoveCharacter(text1.Text)
    3. End Sub
    On error goto Trap

    Trap:
    in case of emergency, drop the case...

    ****************************************
    If this post has been resolved. Please mark it as "Resolved" by going through the "Thread Tools" above and clicking on the "Mark Thread Resolved " option.
    if a post is helpful to you, Please Rate it by clicking on the Rate link right below the avatar

  8. #8

    Thread Starter
    Addicted Member
    Join Date
    Jan 2006
    Posts
    219

    Re: Removing Specific text in a listbox

    thank you all! Appreciated the help

  9. #9
    Software Carpenter dee-u's Avatar
    Join Date
    Feb 2005
    Location
    Pinas
    Posts
    11,127

    Re: [RESOLVED] Removing Specific text in a listbox

    Glad to be of help...
    Regards,


    As a gesture of gratitude please consider rating helpful posts. c",)

    Some stuffs: Mouse Hotkey | Compress file using SQL Server! | WPF - Rounded Combobox | WPF - Notify Icon and Balloon | NetVerser - a WPF chatting system

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