Results 1 to 4 of 4

Thread: Recoloring Syntax

  1. #1

    Thread Starter
    Lively Member
    Join Date
    Dec 2007
    Posts
    85

    Recoloring Syntax

    I've been looking around for this and I can't find an answer. Sometimes I'll find something that's close but not the full answer, and sometimes I'll be reading it and it'll be for a different language. So I'm gonna stop looking and ask here.

    In my program, I open files and they appear in my richtextbox. How would I got about recoloring all instances of a single word inside that richtextbox?

    Syrillia

  2. #2
    Fanatic Member technorobbo's Avatar
    Join Date
    Dec 2008
    Location
    Chicago
    Posts
    864

    Re: Recoloring Syntax

    Code:
    Private Sub Text1_KeyPress(KeyAscii As Integer)
    Dim found As Long
    If KeyAscii = 13 Then
        RichTextBox1.HideSelection = False
    
        found = RichTextBox1.Find(Text1.Text, 0, , rtfWholeWord)
    
        While found <> -1
            RichTextBox1.SelColor = RGB(255, 0, 0)
            found = RichTextBox1.Find(Text1.Text, found + 1, , rtfWholeWord)
    
        Wend
    
    End If
    End Sub
    Have Fun,

    TR
    _____________________________
    Check out my Alpha DogFighter2D Game Demo and Source code. Direct Download:http://home.comcast.net/~technorobbo/Alpha.zip or Read about it in the forum:http://www.vbforums.com/showthread.php?t=551700. Now in 3D!!! http://home.comcast.net/~technorobbo/AlPha3D.zip or read about it in the forum: http://www.vbforums.com/showthread.php?goto=newpost&t=552560 and IChessChat3D internet chess game

  3. #3
    Discovering Life Siddharth Rout's Avatar
    Join Date
    Feb 2005
    Location
    Mumbai, India
    Posts
    12,001

    Re: Recoloring Syntax

    Nice code technorobbo but it will not work efficiently with Keypress 13

    I have attached a very basic example on how to use it...

    Hope this helps...

    Note: If you want to capture keypress 13 (for enter) or Ctrl +V (if user pastes data in the RTB) or when user simply types it and want the coloring to happen automatically then there is a different set of codes that you need to follow... (Check out the Code Generator link in my signature... it follows that principle)
    Attached Files Attached Files
    A good exercise for the Heart is to bend down and help another up...
    Please Mark your Thread "Resolved", if the query is solved


    MyGear:
    ★ CPU ★ Ryzen 5 5800X
    ★ GPU ★ NVIDIA GeForce RTX 3080 TI Founder Edition
    ★ RAM ★ G. Skill Trident Z RGB 32GB 3600MHz
    ★ MB ★ ASUS TUF GAMING X570 (WI-FI) ATX Gaming
    ★ Storage ★ SSD SB-ROCKET-1TB + SEAGATE 2TB Barracuda IHD
    ★ Cooling ★ NOCTUA NH-D15 CHROMAX BLACK 140mm + 10 of Noctua NF-F12 PWM
    ★ PSU ★ ANTEC HCG-1000-EXTREME 1000 Watt 80 Plus Gold Fully Modular PSU
    ★ Case ★ LIAN LI PC-O11 DYNAMIC XL ROG (BLACK) (G99.O11DXL-X)
    ★ Monitor ★ LG Ultragear 27" 240Hz Gaming Monitor
    ★ Keyboard ★ TVS Electronics Gold Keyboard
    ★ Mouse ★ Logitech G502 Hero

  4. #4
    Fanatic Member technorobbo's Avatar
    Join Date
    Dec 2008
    Location
    Chicago
    Posts
    864

    Re: Recoloring Syntax

    Nice code , it definitely does what I often neglect to do. Show the possibilities.
    Have Fun,

    TR
    _____________________________
    Check out my Alpha DogFighter2D Game Demo and Source code. Direct Download:http://home.comcast.net/~technorobbo/Alpha.zip or Read about it in the forum:http://www.vbforums.com/showthread.php?t=551700. Now in 3D!!! http://home.comcast.net/~technorobbo/AlPha3D.zip or read about it in the forum: http://www.vbforums.com/showthread.php?goto=newpost&t=552560 and IChessChat3D internet chess game

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