Results 1 to 14 of 14

Thread: [RESOLVED] Remove line from richtextbox

  1. #1

    Thread Starter
    Junior Member
    Join Date
    Aug 2008
    Posts
    21

    Resolved [RESOLVED] Remove line from richtextbox

    I'm trying to figure out how to remove a specified line, If you've used yahoo chat before and ignored a user and seen, his name and what he's said simpley just dissapear?

    well i know that yahoo uses a html for there chat, but im trying to do the same thing with richtextbox, any advice would be appreciated. ;]

  2. #2
    PowerPoster RhinoBull's Avatar
    Join Date
    Mar 2004
    Location
    New Amsterdam
    Posts
    24,132

    Re: Remove line from richtextbox

    Welcome to Forums!

    Some time ago I came across this sample which strikes through entire line when dblclicked.
    you may reuse that technic but you will also need to find some keyword so you know where the line begins.
    The following sample will delete single (very first) occurence of say lines beginning with "user2:"
    Code:
    Private Sub Command1_Click()
    Dim StarPoint As Long
    
        startpoint = InStr(1, RichTextBox1.Text, "user2:")
        If startpoint > 0 Then
            RichTextBox1.SelStart = startpoint
            DeleteLine RichTextBox1    '<<< I purposely renamed original procedure
        End If
    
    End Sub
    In the StrikeLine procedure (available through that link) you will need to replace last line:

    rch.SelStrikeThru = Not rch.SelStrikeThru

    with this:

    rch.SelText = ""


    Also, to get rid of all occurences you will need to loop while InStr returns result greater than zero.

  3. #3

  4. #4

    Thread Starter
    Junior Member
    Join Date
    Aug 2008
    Posts
    21

    Re: Remove line from richtextbox

    EDIT:

    NEVER MIND. JCIS's works just fine and doesnt remove the color,
    how ever. martinliss's works great except it does remove the color,

    thanks for the help guys ;]

  5. #5
    Freelancer akhileshbc's Avatar
    Join Date
    Jun 2008
    Location
    Trivandrum, Kerala, India
    Posts
    7,652

    Re: Remove line from richtextbox

    The code that I had posted here has some copyrights. So, I am removing it, as instructed by Rhino in the below post.
    Sorry for posting that copyprotected code. I had posted it with some changes, as a solution to this thread. I was not aware that the code was copyprotected, at the time of posting.
    Sorry again
    -Akhilesh
    Last edited by akhileshbc; Sep 1st, 2008 at 08:47 AM.

    If my post was helpful to you, then express your gratitude using Rate this Post.
    And if your problem is SOLVED, then please Mark the Thread as RESOLVED (see it in action - video)
    My system: AMD FX 6100, Gigabyte Motherboard, 8 GB Crossair Vengance, Cooler Master 450W Thunder PSU, 1.4 TB HDD, 18.5" TFT(Wide), Antec V1 Cabinet

    Social Group: VBForums - Developers from India


    Skills: PHP, MySQL, jQuery, VB.Net, Photoshop, CodeIgniter, Bootstrap,...

  6. #6

    Thread Starter
    Junior Member
    Join Date
    Aug 2008
    Posts
    21

    Re: Remove line from richtextbox

    Okay, I've gotta it down to the point where i can remove the exact line by number. With out loosing the color of the text that's left. a bit shorter then tha last post and some adjustments from other post.

    Now Step 2, How to the Line Index by searching by "String" example;
    Find = "<Username>" and figure out what it's index is..

    Step 3, would be to re-insert the line that was removed, say if the user was UNIGNORED.. anyways im not to worried about that yet. ;]

  7. #7

  8. #8

    Thread Starter
    Junior Member
    Join Date
    Aug 2008
    Posts
    21

    Re: Remove line from richtextbox

    oh wah, its vb6, if you think about it, ALL code can be copyrighted.. most of half of anyones projects im shure some part of it has been copyrighted somewhere. weather you know about it OR not.

    anyways, *bump* i searched msdn, and google last night. I came across a couple of things on msdn, well the const, and all they show u is how sendmessage works, wich i already know how it works but they don't give you a heads up on how to use the constants. :[

  9. #9
    PowerPoster RhinoBull's Avatar
    Join Date
    Mar 2004
    Location
    New Amsterdam
    Posts
    24,132

    Re: Remove line from richtextbox

    Quote Originally Posted by siklife1
    oh wah, its vb6, if you think about it, ALL code can be copyrighted... most of half of anyones projects im shure some part of it has been copyrighted somewhere.
    No, I'm afraid you have a wrong idea. Lots of public websites offer "free' code which is copyrighted in vast majority cases.
    If you read disclosure statement you will find something similar to this:
    "you may freely use and distribute this code in your own application however do not replicate it or post it on any website, magazine, etc..."

    Don't you think that it's a fair demand from the author who spent his/her time developing that sample that will save you lots of time and frustration?
    Think about it again.

  10. #10

    Thread Starter
    Junior Member
    Join Date
    Aug 2008
    Posts
    21

    Re: Remove line from richtextbox

    I've thought about it, and despite what anyones written, it's already have been done before, probley word for word. when it comes to helping others. But whining over some code 300 other people wrote exaclty the same is useless, Specially in an un-supported language.


    Anyways please stay on topic before destroying my only thread with nonsence. Like i said, help will be appreciated.

    The current problem is to get the Line.Index of tha text found, What can be a good alternitive to find the index line of a certain string. Thanks! ;]

  11. #11

  12. #12

    Thread Starter
    Junior Member
    Join Date
    Aug 2008
    Posts
    21

    Re: Remove line from richtextbox

    Quote Originally Posted by RhinoBull
    I'm speachless...

    Anyway, you had been provided with 3 working solutions but misteriously you failed to implement any of it.
    I'm not sure what kind of help you're looking.

    Sorry pal.

    The 3 solutions provided with minor change work perfectly for me, but now im onto another differnt problem that's relevent to what im askin here so why make a whole new thread?

    The previous posters 'have solved' my first problem.

    now if anyone has any idea on solving my next proble, i'd be intrested in hearing about it!! ;] so there for!

    *bumpie*

  13. #13

  14. #14

    Thread Starter
    Junior Member
    Join Date
    Aug 2008
    Posts
    21

    [Resolved] Remove line from richtextbox

    Quote Originally Posted by RhinoBull
    It's never a bad idea to open new thread if original question has been answered - keeping basically resolved thread open forever may confuse many responders.

    That's true i suppose, but i didn't see why opening a new thread when the issues has to do with the same control and idea concept anyway, people how ever can become confused because this thread now has alot of useless posts.

    Off to make a new thread then.

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