Hi all,
I decided to view my sql queries in a richtext box but when I loaded my query obviously I cannot syntax highlighting like SSMS.
So I decided to use regex to plit each line and when I find some words like select, I change colour to it.
This is code
I don't know if it a best method but it works fine.
My issue in this method is to highlight sql comments like
For first string
regex splis it as:
So I don't know why in my split I find "" and I don't know which is regex syntax to remove it.
How can I remove "" char?
Thank in advanced
gio
I decided to view my sql queries in a richtext box but when I loaded my query obviously I cannot syntax highlighting like SSMS.
So I decided to use regex to plit each line and when I find some words like select, I change colour to it.
This is code
Code:
...
Dim s As Regex = New Regex("([ \,;()'*-])")
Dim word1 As String()
word1 = s.Split(linea)
For i = 0 To word1.Length - 1
RichTextBox1.SelectionFont = New Font("Courier New", 10, FontStyle.Regular)
RichTextBox1.SelectionColor = Color.Black
keywords = {"select", "distinct", "case", "when", "end", "as", "else", "then", "varchar", "where", "on", "from"}
If keywords.Contains(LCase(word1(i))) Then
RichTextBox1.SelectionColor = Color.Blue
RichTextBox1.SelectionFont = New Font("Courier New", 10, FontStyle.Bold)
End If
RichTextBox1.SelectedText = word1(i)
...My issue in this method is to highlight sql comments like
Code:
/****** Script for SelectTopNRows command from SSMS ******/
or
--,case when len(a.[mycity])=5 then c.mycity else a.mycity end as mycityregex splis it as:
Code:
"/"
"*"
""
"*"
""
"*"
...How can I remove "" char?
Thank in advanced
gio