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:
  1. Private Sub cmdConvert_Click()
  2.     Dim x As Integer
  3.     txtColored.Text = ""
  4.     For x = 1 To Len(txtCode.Text)
  5.         If Mid(txtCode.Text, x, 1) = "^" Then
  6.             If Mid(txtCode.Text, x + 1, 1) = 0 Then
  7.                 txtColored.SelColor = vbBlack
  8.             ElseIf Mid(txtCode.Text, x + 1, 1) = 1 Then
  9.                 txtColored.SelColor = vbRed
  10.             ElseIf Mid(txtCode.Text, x + 1, 1) = 2 Then
  11.                 txtColored.SelColor = vbYellow
  12.             ElseIf Mid(txtCode.Text, x + 1, 1) = 3 Then
  13.                 txtColored.SelColor = vbGreen
  14.             ElseIf Mid(txtCode.Text, x + 1, 1) = 4 Then
  15.                 txtColored.SelColor = vbBlue
  16.             End If
  17.             x = x + 1
  18.         Else
  19.             txtColored.SelText = Mid(txtCode.Text, x, 1)
  20.         End If
  21.     Next x
  22. End Sub