Results 1 to 7 of 7

Thread: more richtext woes...

  1. #1

    Thread Starter
    The Devil crptcblade's Avatar
    Join Date
    Aug 2000
    Location
    Quetzalshacatenango
    Posts
    9,091

    Unhappy

    Code:
    Private Sub MakeColored()
        For x = 1 To Len(rtfbox.Text)
            If Mid(rtfbox.Text, x, Len("SELECT")) = "SELECT" Then
                rtfbox.SelStart = x - 1
                rtfbox.SelLength = Len("SELECT")
                rtfbox.SelColor = vbBlue
                rtfbox.SelLength = 0
                rtfbox.SelColor = vbBlack
                x = (x - 1) + Len("SELECT")
            Else
                rtfbox.SelColor = vbBlack
            End If
        Next x
    
        rtfbox.SelStart = Len(rtfbox.Text)
    End Sub
    I havve this code to look for the word "SELECT" in a RichTextBox, and if found, color it blue. This works the first time, but if I run the code again, it colors evrything blue! Who can tell me why?
    Laugh, and the world laughs with you. Cry, and you just water down your vodka.


    Take credit, not responsibility

  2. #2
    _______ HeSaidJoe's Avatar
    Join Date
    Jun 1999
    Location
    Canada
    Posts
    3,946

    <?>

    It doesn't for me. Works fine..even if I click it 10 times the only work blue is Select
    "A myth is not the succession of individual images,
    but an integerated meaningful entity,
    reflecting a distinct aspect of the real world."

    ___ Adolf Jensen

  3. #3

    Thread Starter
    The Devil crptcblade's Avatar
    Join Date
    Aug 2000
    Location
    Quetzalshacatenango
    Posts
    9,091
    here's the thing, It does that for me too, but then I go to the next line in the box, add some more text, and run it again, and that's where it screws up...I don't know...

    EDIT

    I have it on the KeyPress event and it runs when the ENTER key is pressed...
    Laugh, and the world laughs with you. Cry, and you just water down your vodka.


    Take credit, not responsibility

  4. #4

    Thread Starter
    The Devil crptcblade's Avatar
    Join Date
    Aug 2000
    Location
    Quetzalshacatenango
    Posts
    9,091
    I'm back...
    Laugh, and the world laughs with you. Cry, and you just water down your vodka.


    Take credit, not responsibility

  5. #5
    Guest
    Reset all the text to black before colouring the text again. Ok, so it's a brute force approach, but it should work.

    - gaffa

  6. #6

    Thread Starter
    The Devil crptcblade's Avatar
    Join Date
    Aug 2000
    Location
    Quetzalshacatenango
    Posts
    9,091
    Alright, I'll try that...
    Laugh, and the world laughs with you. Cry, and you just water down your vodka.


    Take credit, not responsibility

  7. #7

    Thread Starter
    The Devil crptcblade's Avatar
    Join Date
    Aug 2000
    Location
    Quetzalshacatenango
    Posts
    9,091
    cool, that worked, thanks gaffa...
    Laugh, and the world laughs with you. Cry, and you just water down your vodka.


    Take credit, not responsibility

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