I wrote this little program for syntax coloring somthing (letters ect).

But It gives me the error "cannot convert Number to integer" With the first case. Can some one help?

VB Code:
  1. Private Sub RichTextBox_TextChanged(ByVal sender As System.Object, ByVal e As System.EventArgs) Handles RichTextBox.TextChanged
  2.         Dim source As String
  3.  
  4.         Dim rtb As New RichTextBox ' name rtb as a RichText Box type
  5.         Dim Codearray() As String ' It's the array of text
  6.         Dim currentline As String ' The currentline of Text
  7.         Dim Line As Integer ' Dunno why I can't use somthing smaller ...
  8.         Dim I As Decimal 'Largestest thing
  9.         Codearray = Split(source, vbCrLf) ' split Code array from source at Center Left
  10.         For I = LBound(Codearray) To UBound(Codearray) 'From lower case to uppercase
  11.             currentline = Codearray(I) ' Code array for line
  12.             ' add auto tab
  13.             Select Case Left() ' the left case
  14.                 Case "\" ' comments
  15.                     rtb.Text = currentline ' trb on current line
  16.                     rtb.SelectedText = Len(currentline) ' select text
  17.                     rtb.SelectionFont = New Font(rtb.SelectionFont, FontStyle.Italic) ' make her bold!
  18.                     rtb.ForeColor() = Drawing.Color.Gray  'Change color
  19.                     rtb.SelectedRtf = rtb.Text = Chr(10) & Chr(13)
  20.  
  21.                 Case "!" ' normal number
  22.                     rtb.Text = currentline ' trb on current line
  23.                     rtb.SelectedText = Len(currentline) ' select text
  24.                     rtb.SelectionFont = New Font(rtb.SelectionFont, FontStyle.Strikeout) ' make her bold!
  25.                     rtb.ForeColor() = Drawing.Color.Purple 'Change color
  26.                     rtb.SelectedRtf = rtb.Text = Chr(10) & Chr(13)
  27.                 Case "&" ' Literal
  28.                     rtb.Text = currentline ' trb on current line
  29.                     rtb.SelectedText = Len(currentline) ' select text
  30.                     rtb.SelectionFont = New Font(rtb.SelectionFont, FontStyle.Regular) ' make her bold!
  31.                     rtb.ForeColor() = Drawing.Color.Green  'Change color
  32.                     rtb.SelectedRtf = rtb.Text = Chr(10) & Chr(13)
  33.                 Case "%" ' Small number
  34.                     rtb.Text = currentline ' trb on current line
  35.                     rtb.SelectedText = Len(currentline) ' select text
  36.                     rtb.SelectionFont = New Font(rtb.SelectionFont, FontStyle.Regular) ' make her bold!
  37.                     rtb.ForeColor() = Drawing.Color.DarkRed 'Change color
  38.                     rtb.SelectedRtf = rtb.Text = Chr(10) & Chr(13)
  39.                 Case ""
  40.                     rtb.Text = currentline ' trb on current line
  41.                     rtb.SelectedText = Len(currentline) ' select text
  42.                     rtb.SelectionFont = New Font(rtb.SelectionFont, FontStyle.Bold) ' make her bold!
  43.                     rtb.ForeColor() = Drawing.Color.AntiqueWhite 'Change color
  44.                     rtb.SelectedRtf = rtb.Text = Chr(10) & Chr(13)
  45.                 Case "(" ' comments
  46.                     rtb.Text = currentline ' trb on current line
  47.                     rtb.SelectedText = Len(currentline) ' select text
  48.                     rtb.SelectionFont = New Font(rtb.SelectionFont, FontStyle.Italic) ' make her bold!
  49.                     rtb.ForeColor() = Drawing.Color.Bisque  'Change color
  50.                     rtb.SelectedRtf = rtb.Text = Chr(10) & Chr(13)
  51.                 Case ")" ' normal number
  52.                     rtb.Text = currentline ' trb on current line
  53.                     rtb.SelectedText = Len(currentline) ' select text
  54.                     rtb.SelectionFont = New Font(rtb.SelectionFont, FontStyle.Strikeout) ' make her bold!
  55.                     rtb.ForeColor() = Drawing.Color.Bisque 'Change color
  56.                     rtb.SelectedRtf = rtb.Text = Chr(10) & Chr(13)
  57.                 Case "{" ' Literal
  58.                     rtb.Text = currentline ' trb on current line
  59.                     rtb.SelectedText = Len(currentline) ' select text
  60.                     rtb.SelectionFont = New Font(rtb.SelectionFont, FontStyle.Regular) ' make her bold!
  61.                     rtb.ForeColor() = Drawing.Color.Brown 'Change color
  62.                     rtb.SelectedRtf = rtb.Text = Chr(10) & Chr(13)
  63.                 Case "}" ' Small number
  64.                     rtb.Text = currentline ' trb on current line
  65.                     rtb.SelectedText = Len(currentline) ' select text
  66.                     rtb.SelectionFont = New Font(rtb.SelectionFont, FontStyle.Regular) ' make her bold!
  67.                     rtb.ForeColor() = Drawing.Color.Brown 'Change color
  68.                     rtb.SelectedRtf = rtb.Text = Chr(10) & Chr(13)
  69.                 Case ":"
  70.                     rtb.Text = currentline ' trb on current line
  71.                     rtb.SelectedText = Len(currentline) ' select text
  72.                     rtb.SelectionFont = New Font(rtb.SelectionFont, FontStyle.Bold) ' make her bold!
  73.                     rtb.ForeColor() = Drawing.Color.Pink 'Change color
  74.                     rtb.SelectedRtf = rtb.Text = Chr(10) & Chr(13)
  75.                     If InStr(1, currentline, "(") > 0 Then
  76.                         rtb.TabIndex = 1
  77.  
  78.                         Dim comment As Long
  79.                         comment = InStr(InStr(1, currentline, ")"), currentline, "*")
  80.  
  81.                         rtb.SelectedRtf = rtb.SelectedRtf & Chr(10) & Chr(13)
  82.                     End If
  83.                 Case Else
  84.                     rtb.Text = currentline ' trb on current line
  85.                     rtb.SelectedText = Len(currentline) ' select text
  86.                     rtb.SelectionFont = New Font(rtb.SelectionFont, FontStyle.Bold) ' make her bold!
  87.                     rtb.BackColor() = Drawing.Color.Red 'Change color
  88.                     rtb.SelectedRtf = rtb.Text = Chr(10) & Chr(13)
  89.             End Select
  90.         Next
  91.     End Sub