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?
Printable View
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?
What do you mean highlight words in the VB IDE? Changing the colour, font etc of your code?
If so, Tools->Options->Editor Format.
no i mean how can i color words like in vb IDE in a RTB box
?????
Try and search for "Richtext" and "Color", there's a whole sh**load of well documented examples to be found in this forum.Code:RichtextBox1.SelColor=vbGreen
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:
Option Explicit Private Sub cmdHighlight_Click() Dim srchT As Integer Dim srchIDE As Integer Dim stringIDE() As String stringIDE = Split("Visual Basic;Compile;Debug;", Chr$(59), -1) For srchT = 1 To Len(rtfBox.Text) Step 1 For srchIDE = 0 To UBound(stringIDE()) If LCase(Mid(rtfBox.Text, srchT, Len(stringIDE(srchIDE)))) = LCase(stringIDE(srchIDE)) Then With rtfBox .SelStart = srchT - 1 .SelLength = Len(stringIDE(srchIDE)) .SelColor = &HFF End With: Exit For End If Next srchIDE Next srchT End Sub
Quote:
Originally Posted by vicros
no spam please
are you sure this is fast enough for a whole script?Quote:
Originally Posted by Luke K
Originally Posted by nareth
huh?Quote:
no spam please
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.
woulndt it be better to get the current line and highlight the words on that if the current line changes like in vb IDE
Sure, you can do that if you want. I'm not stopping you :bigyello:
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.
how would i do this
bump