解析:
简单的:
Private Sub Command1_Click()
RichTextBox1.SelStart = 2
RichTextBox1.SelLength = 1
RichTextBox1.SelColor = vbRed
End Sub
更人性化的:
Private Sub Command1_Click()
Dim MySelStart As Integer, MySelLength As Integer
MySelStart = RichTextBox1.SelStart
MySelLength = RichTextBox1.SelLength
'选定第三个字符,并且颜色设为红色
RichTextBox1.SelStart = 2
RichTextBox1.SelLength = 1
RichTextBox1.SelColor = vbRed
'恢复之前的光标位置和选定长度
RichTextBox1.SelStart = MySelStart
RichTextBox1.SelLength = MySelLength
End Sub
Colorflag = "red"richtextbox.SelectionColor = Color.FromName(Colorflag)
这个就是将选中的文本变色
你可以匹配注释然后将其选中最后改变颜色(程序实现)
欢迎分享,转载请注明来源:内存溢出
评论列表(0条)