Try something like this:
Code:Private Sub Command1_Click() Dim intPos As Integer Dim intOldPos As Integer With RichTextBox1 'Get position of the "1)" intPos = InStr(.Text, "1)") intPos = intPos + Len("1)") If intPos Then .SelStart = 0 .SelLength = intPos .SelColor = vbYellow End If 'Memorize last position intOldPos = intPos 'Get position of the filename intPos = InStr(intOldPos, UCase(.Text), "TEST.ZIP") intPos = intPos + Len("TEST.ZIP") If intPos Then .SelStart = intOldPos .SelLength = intPos - intOldPos .SelColor = vbRed End If 'Colorize the rest of the text with blue .SelStart = intPos + 1 .SelLength = Len(.Text) - intPos .SelColor = vbBlue .SelStart = Len(.Text) End With End Sub




Reply With Quote