PrivateSubRichTextBox1_TextChanged()SubRichTextBox1_TextChanged(ByValsenderAsSystem.Object,ByValeAsSystem.EventArgs)HandlesRichTextBox1.TextChangedDimiAsInteger=RichTextBox1.SelectionStartDimtagetstringAsString=intext.TextDimstrAsString=RichTextBox1.TextDimtoalAsIntegerstr=RichTextBox1.TextRichTextBox1.SelectionStart=0RichTextBox1.SelectionLength=str.LengthRichTextBox1.SelectionColor=Color.BlackFortoal=1Tostr.LengthIfMid(str,toal,1)<>Mid(tagetstring,toal,1)ThenRichTextBox1.SelectionStart=toal-1RichTextBox1.SelectionLength=1RichTextBox1.SelectionColor=Color.RedEndIfNextRichTextBox1.SelectionStart=iRichTextBox1.SelectionLength=0EndSub ’第二版DimtagetstringAsString=intext.TextDimstrAsString=RichTextBox1.TextDimstrsubAsInteger=str.Length-strbuff.Lengthrtbsellen=RichTextBox1.SelectionLengthrtbselstart=RichTextBox1.SelectionStartRichTextBox1.SelectionStart=0RichTextBox1.SelectionLength=str.LengthRichTextBox1.SelectionColor=Color.BlackDimiAsInteger=0Fori=1Tostr.LengthIfMid(str,i,1)<>Mid(tagetstring,i,1)ThenRichTextBox1.SelectionStart=i-1RichTextBox1.SelectionLength=1RichTextBox1.SelectionColor=Color.RedEndIfNextRichTextBox1.SelectionStart=rtbselstartRichTextBox1.SelectionLength=rtbsellenstrbuff=RichTextBox1.Text PublicClassForm1DimstrbuffAsString=""DimrtbselstartAsIntegerDimrtbsellenAsIntegerPrivateSubRichTextBox1_TextChanged(ByValsenderAsSystem.Object,ByValeAsSystem.EventArgs)HandlesRichTextBox1.TextChangedDimtagetstringAsString=intext.TextDimstrAsString=RichTextBox1.TextDimstrsubAsInteger=str.Length-strbuff.Lengthrtbsellen=RichTextBox1.SelectionLengthrtbselstart=RichTextBox1.SelectionStartRichTextBox1.SelectionStart=0RichTextBox1.SelectionLength=str.LengthRichTextBox1.SelectionColor=Color.BlackDimiAsInteger=0Fori=1Tostr.LengthIfMid(str,i,1)<>Mid(tagetstring,i,1)ThenRichTextBox1.SelectionStart=i-1RichTextBox1.SelectionLength=1RichTextBox1.SelectionColor=Color.RedEndIfNextRichTextBox1.SelectionStart=rtbselstartRichTextBox1.SelectionLength=rtbsellenstrbuff=RichTextBox1.TextEndSubEndClass