Hi,
i want to be able to colourise words in 2 different objects, richtextbox and listbox control, the code below got the rtb sorted..but i dont know how to use it for both, could somebody help make a module or something to do such a thing if possible.
VB Code:
Private Sub cmdConvert_Click() Dim x As Integer txtColored.Text = "" For x = 1 To Len(txtCode.Text) If Mid(txtCode.Text, x, 1) = "^" Then If Mid(txtCode.Text, x + 1, 1) = 0 Then txtColored.SelColor = vbBlack ElseIf Mid(txtCode.Text, x + 1, 1) = 1 Then txtColored.SelColor = vbRed ElseIf Mid(txtCode.Text, x + 1, 1) = 2 Then txtColored.SelColor = vbYellow ElseIf Mid(txtCode.Text, x + 1, 1) = 3 Then txtColored.SelColor = vbGreen ElseIf Mid(txtCode.Text, x + 1, 1) = 4 Then txtColored.SelColor = vbBlue End If x = x + 1 Else txtColored.SelText = Mid(txtCode.Text, x, 1) End If Next x End Sub




Reply With Quote