Results 1 to 14 of 14

Thread: Coloring RTB

  1. #1

    Thread Starter
    Banned nareth's Avatar
    Join Date
    Jun 2004
    Posts
    1,206

    Coloring RTB

    ok i want to color some words like in the VB IDE.
    can anyone show me a very fast example.
    also how do i get current line of RTB?

  2. #2
    Addicted Member Luke K's Avatar
    Join Date
    Jun 2004
    Location
    Perth, Australia
    Posts
    183

    Re: Coloring RTB

    What do you mean highlight words in the VB IDE? Changing the colour, font etc of your code?

    If so, Tools->Options->Editor Format.
    Artificial Intelligence At War! - The best game of its genre
    Program your own robot and watch it fight in 3d!
    Droidarena 3

    If I have been useful, please Rate My Post

    Support FireFox -
    Microsoft Visual Studio .NET Professional 2003
    Microsoft Visual Studio 6, Enterprise Edition
    Microsoft Windows XP Professional, Service Pack 2

  3. #3

    Thread Starter
    Banned nareth's Avatar
    Join Date
    Jun 2004
    Posts
    1,206

    Re: Coloring RTB

    no i mean how can i color words like in vb IDE in a RTB box

  4. #4

    Thread Starter
    Banned nareth's Avatar
    Join Date
    Jun 2004
    Posts
    1,206

    Re: Coloring RTB

    ?????

  5. #5
    Lively Member
    Join Date
    Oct 2001
    Posts
    125

    Re: Coloring RTB

    Code:
    RichtextBox1.SelColor=vbGreen
    Try and search for "Richtext" and "Color", there's a whole sh**load of well documented examples to be found in this forum.

  6. #6
    Addicted Member Luke K's Avatar
    Join Date
    Jun 2004
    Location
    Perth, Australia
    Posts
    183

    Re: Coloring RTB

    Relatively simple but you must manually input the words you want highlighted in the Expression argument of the Split() function iv used delimited by semi-colons. In my example, "Visual Basic", "Compile" and "Debug" will be highlighted.

    VB Code:
    1. Option Explicit
    2.  
    3. Private Sub cmdHighlight_Click()
    4.  
    5.     Dim srchT As Integer
    6.     Dim srchIDE As Integer
    7.     Dim stringIDE() As String
    8.  
    9.     stringIDE = Split("Visual Basic;Compile;Debug;", Chr$(59), -1)
    10.     For srchT = 1 To Len(rtfBox.Text) Step 1
    11.         For srchIDE = 0 To UBound(stringIDE())
    12.             If LCase(Mid(rtfBox.Text, srchT, Len(stringIDE(srchIDE)))) = LCase(stringIDE(srchIDE)) Then
    13.                 With rtfBox
    14.                     .SelStart = srchT - 1
    15.                     .SelLength = Len(stringIDE(srchIDE))
    16.                     .SelColor = &HFF
    17.                 End With: Exit For
    18.             End If
    19.         Next srchIDE
    20.     Next srchT
    21.  
    22. End Sub
    Attached Images Attached Images  
    Last edited by Luke K; Jan 5th, 2005 at 11:20 AM. Reason: Debug
    Artificial Intelligence At War! - The best game of its genre
    Program your own robot and watch it fight in 3d!
    Droidarena 3

    If I have been useful, please Rate My Post

    Support FireFox -
    Microsoft Visual Studio .NET Professional 2003
    Microsoft Visual Studio 6, Enterprise Edition
    Microsoft Windows XP Professional, Service Pack 2

  7. #7

    Thread Starter
    Banned nareth's Avatar
    Join Date
    Jun 2004
    Posts
    1,206

    Re: Coloring RTB

    Quote Originally Posted by vicros
    Code:
    RichtextBox1.SelColor=vbGreen
    Try and search for "Richtext" and "Color", there's a whole sh**load of well documented examples to be found in this forum.

    no spam please

  8. #8

    Thread Starter
    Banned nareth's Avatar
    Join Date
    Jun 2004
    Posts
    1,206

    Re: Coloring RTB

    Quote Originally Posted by Luke K
    Relatively simple but you must manually input the words you want highlighted in the Expression argument of the Split() function iv used delimited by semi-colons. In my example, "Visual Basic", "Compile" and "Debug" will be highlighted.

    VB Code:
    1. Option Explicit
    2.  
    3. Private Sub cmdHighlight_Click()
    4.  
    5.     Dim srchT As Integer
    6.     Dim srchIDe As Integer
    7.     Dim stringIDE() As String
    8.  
    9.     stringIDE = Split("Visual Basic;Compile;Debug;", Chr$(59), -1)
    10.     For srchT = 1 To Len(rtfBox.Text) Step 1
    11.         For srchIDe = 0 To UBound(stringIDE())
    12.             If Mid(rtfBox.Text, srchT, Len(stringIDE(srchIDe))) = stringIDE(srchIDe) Then
    13.                 With rtfBox
    14.                     .SelStart = srchT - 1
    15.                     .SelLength = Len(stringIDE(srchIDe))
    16.                     .SelColor = &HFF
    17.                 End With: Exit For
    18.             End If
    19.         Next srchIDe
    20.     Next srchT
    21.  
    22. End Sub
    are you sure this is fast enough for a whole script?

  9. #9
    Lively Member
    Join Date
    Oct 2001
    Posts
    125

    Re: Coloring RTB

    Originally Posted by nareth
    no spam please
    huh?

  10. #10
    Addicted Member Luke K's Avatar
    Join Date
    Jun 2004
    Location
    Perth, Australia
    Posts
    183

    Re: Coloring RTB

    It is the fastest way I can think of. If the script is big, give the user something to look at, a progressbar perhaps that shows the progress of the highlighting.
    Artificial Intelligence At War! - The best game of its genre
    Program your own robot and watch it fight in 3d!
    Droidarena 3

    If I have been useful, please Rate My Post

    Support FireFox -
    Microsoft Visual Studio .NET Professional 2003
    Microsoft Visual Studio 6, Enterprise Edition
    Microsoft Windows XP Professional, Service Pack 2

  11. #11

    Thread Starter
    Banned nareth's Avatar
    Join Date
    Jun 2004
    Posts
    1,206

    Re: Coloring RTB

    woulndt it be better to get the current line and highlight the words on that if the current line changes like in vb IDE

  12. #12
    Addicted Member Luke K's Avatar
    Join Date
    Jun 2004
    Location
    Perth, Australia
    Posts
    183

    Re: Coloring RTB

    Sure, you can do that if you want. I'm not stopping you
    You would still have to keep a count of where that word starts in the whole of the text plus the position of the text that starts in the line.
    Last edited by Luke K; Jan 5th, 2005 at 11:36 AM.
    Artificial Intelligence At War! - The best game of its genre
    Program your own robot and watch it fight in 3d!
    Droidarena 3

    If I have been useful, please Rate My Post

    Support FireFox -
    Microsoft Visual Studio .NET Professional 2003
    Microsoft Visual Studio 6, Enterprise Edition
    Microsoft Windows XP Professional, Service Pack 2

  13. #13

    Thread Starter
    Banned nareth's Avatar
    Join Date
    Jun 2004
    Posts
    1,206

    Re: Coloring RTB

    how would i do this

  14. #14

    Thread Starter
    Banned nareth's Avatar
    Join Date
    Jun 2004
    Posts
    1,206

    Re: Coloring RTB

    bump

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