十年网站开发经验 + 多家企业客户 + 靠谱的建站团队
量身定制 + 运营维护+专业推广+无忧售后,网站问题一站解决
Private Sub RichTextBox1_TextChanged(ByVal sender As System.Object, ByVal e As System.EventArgs) Handles RichTextBox1.TextChanged
创新互联公司专注于网站建设|成都网站维护|优化|托管以及网络推广,积累了大量的网站设计与制作经验,为许多企业提供了网站定制设计服务,案例作品覆盖纯水机等行业。能根据企业所处的行业与销售的产品,结合品牌形象的塑造,量身开发品质网站。
Dim pos = RichTextBox1.SelectionStart
Dim i As String = Regex.Matches(RichTextBox1.Text, "\bDim\b").ToString
RichTextBox1.SelectAll
RichTextBox1.SelectionColor = Color.Black
If Regex.IsMatch(RichTextBox1.Text, "\bDim\b") = True Then
For Each mat As Match In Regex.Matches(RichTextBox1.Text, "\bDim\b")
RichTextBox1.SelectionStart = mat.Index
RichTextBox1.SelectionLength = mat.Length
RichTextBox1.SelectionColor = Color.YellowGreen
Next
End If
RichTextBox1.SelectionStart = pos
RichTextBox1.SelectionLength = 0
End Sub
我做了一个更详细的正则:
Friend Keys As String =
"\b(#Const|#If|Then|#Else|#Region|Delegate|Namespace|Class|End|Firend|Partial|Module|Interface|Enum|Shared|Overrides|Overloads|Structure|Let|Const|Dim|As|Private|Public|New|Static|Option|Private|Module|IsArray|IsDate|IsEmpty|IsError|IsMissing|IsNull|IsNumeric|IsObject|TypeName|VarType|Me|Option|Explicit|Mod|Like|Is|Not|And|Or|Xor|Eqv|Imp|Clear|Error|Raise|Error|Err|CVErr|On|Error|Resume|IsError|Collection|Add|Remove|Item|DDB|SLN|SYD|FV|Rate|IRR|MIRR|NPer|IPmt|Pmt|PPmt|NPV|PV|Do|Loop|For|Next|For|Each|Next|While|Wend|With|Choose|If|Then|Else|Select|Case|Switch|Call|Function|Property|Get|Property|Let|Property|Set|Sub|Date|Now|Time|DateAdd|DateDiff|DatePart|DateSerial|DateValue|TimeSerial|TimeValue|Date|Time|Timer|CBool|CByte|CCur|CDate|CDbl|CDec|CInt|CLng|CSng|CStr|CVar|CVErr|Fix|Int|Boolean|Byte|Currency|Date|Double|Integer|Long|Object|Single|String|Object|Atn|Cos|Sin|Tan|Exp|Log|Sqr|Randomize|Rnd|Abs|Sgn|Fix|Int|IsArray|Array|Option|Base|Dim|Private|Public|ReDim|Static|LBound|UBound|Erase|ReDim|DeleteSetting|GetSetting|GetAllSettings|SaveSetting|Chr|Format|LCase|UCase|DateSerial|DateValue|Hex|Oct|Format|Str|CBool|CByte|CCur|CDate|CDbl|CDec|CInt|CLng|CSng|CStr|CVar|CVErr|Fix|Int|Day|Month|Weekday|Year|Hour|Minute|Second|Asc|Val|TimeSerial|TimeValue|StrComp|StrConv|Format|LCase|UCase|Space|String|Len|Format|LSet|RSet|InStr|Left|LTrim|Mid|Right|RTrim|Trim|Option|Compare|Asc|Chr|AppActivate|Shell|SendKeys|Beep|Command)\b"
SCON = 0x50; //REN=1允许串行接受状态,串口工作模式1 TMOD|= 0x20; 试下这个程序,PC发什么,它就回送什么,收到数据,点亮P2.0的LED。
选中就是高亮,首先得到你找到的文本字符的起始位置和长度,然后
TextBox.Select(start,length)
或
TextBox.SelectionStart = start
TextBox.SelectionLength = length
通过使用VB的Timer控件,程序员可以轻松的在窗体上实现闪烁文字的效果。本文将演示如何为Label控件加上闪烁效果,这种方法同样适用于其它多种控件。以下代码可以完成检验ForeColor属性的任务: Private Sub Timer1_Timer() If Label1.ForeColor = Label1.BackColor Then Label1.ForeColor = vbBlack Else Label1.ForeColor = Label1.BackColor End If End Sub 另外,你也可以让文字采用不同的颜色,比如交替采用红色和绿色: Private Sub Timer1_Timer() If Label1.ForeColor = vbRed Then Label1.ForeColor = vbGreen Else Label1.ForeColor = vbRed End If End Sub 当你停止文字闪烁时,还要确定文字的状态是可见的并且采用了合适的色彩。