|
This is the code I am using to format the colors of the text where required. If I dont reformat the existing text it prints without formatting:-
marcfindita = "!" marcfinditb = "*" lengther = Len(marcfindita) totallength = Len(frmFaultview.RichTextBox1.Text) start = 0 Do Until start >= totallength foundpos1 = frmFaultview.RichTextBox1.Find(marcfindita, start, totallength, Text) If foundpos1 = -1 Then Exit Do If foundpos1 <> -1 Then 'exclamation mark found foundpos2 = frmFaultview.RichTextBox1.Find(marcfindita, foundpos1 + 1, totallength, Text) If foundpos2 = -1 Then Exit Do If foundpos2 <> -1 Then frmFaultview.RichTextBox1.SelStart = foundpos1 frmFaultview.RichTextBox1.SelLength = foundpos2 - foundpos1 + 1 frmFaultview.RichTextBox1.SelBold = True frmFaultview.RichTextBox1.SelColor = RGB(255, 0, 0) start = foundpos2 + 1 ' start looking here End If End If Loop lengther = Len(marcfinditb) totallength = Len(frmFaultview.RichTextBox1.Text) start = 0 Do Until start >= totallength foundpos3 = frmFaultview.RichTextBox1.Find(marcfinditb, start, totallength, Text) If foundpos3 = -1 Then Exit Do If foundpos3 <> -1 Then 'asterisk found foundpos4 = frmFaultview.RichTextBox1.Find(marcfinditb, foundpos3 + 1, totallength, Text) If foundpos4 = -1 Then Exit Do If foundpos4 <> -1 Then frmFaultview.RichTextBox1.SelStart = foundpos3 frmFaultview.RichTextBox1.SelLength = foundpos4 - foundpos3 + 1 frmFaultview.RichTextBox1.SelBold = True frmFaultview.RichTextBox1.SelColor = RGB(125, 245, 134) start = foundpos4 + 1 ' start looking here End If End If Loop frmFaultview.RichTextBox1.SelStart = 0 frmFaultview.RichTextBox1.SelBold = False frmFaultview.RichTextBox1.SelColor = RGB(0, 0, 0)
|