Hello, My name is TheMeq and this is my first post. So Hi.
I'll jump straight in.
I am making a code editor to go along side a program I am developing, it uses XML.
What I am looking to do is add syntax highlighting, which I have working for individual strings, but I may have some strings that have some changeable data.
This works fine and dandy, but If I try to do something likeCode:Private Sub RichTextBox1_TextChanged(ByVal sender As System.Object, ByVal e As System.EventArgs) Handles RichTextBox1.TextChanged Dim wordsRED As New List(Of String) wordsRED.ADD("<key>") wordsRED.ADD("</key>") If RichTextBox1.Text.Length > 0 Then Dim selectStart As Integer = RichTextBox1.SelectionStart RichTextBox1.Select(0, RichTextBox1.Text.Length) RichTextBox1.SelectionColor = Color.Black RichTextBox1.DeselectAll() 'Red Colored Words For Each oneWord As String In wordsRED Dim pos As Integer = 0 Do While RichTextBox1.Text.ToUpper.IndexOf(oneWord.ToUpper, pos) >= 0 pos = RichTextBox1.Text.ToUpper.IndexOf(oneWord.ToUpper, pos) RichTextBox1.Select(pos, oneWord.Length) RichTextBox1.SelectionColor = Color.Red pos += 1 Loop Next RichTextBox1.SelectionStart = selectStart RichTextBox1.SelectionLength = 0 End If End Sub
It doesn't recognise the * wildcard. So I am guessing that you can't do it this way, is there any other way to do it?Code:wordsRED.Add("<?xml*?>") wordsRED.Add("<!DOCTYPE*>")
Thanks


Reply With Quote
)
