I need help looping through an array. [SOLVED]
Take a look at this function.
VB Code:
Private Function ColorServerMessageLines()
Dim strArray As String
strArray = Split(rtbServerMessages.Text, vbNewLine)
For i = 0 To strArray - 1
If Left$(strArray(i), 6) = "SYSTEM" Then
rtbServerMessages.SelStart = 0
rtbServerMessages.SelLength = Len(strArray(i))
rtbServerMessages.SelColor = vbDarkGreen
ElseIf Left$(strArray(i), 5) = "ERROR" Then
rtbServerMessages.SelStart = 0
rtbServerMessages.SelLength = Len(strArray(i))
rtbServerMessages.SelColor = vbDarkRed
End If
Next i
End Function
What this code is *supposed to* do is split the contents of my textbox into an array, using the newline character as a delimiter. It should then loop through each of the resulting elements, searching for a specific string at the beginning, and coloring the different lines accordingly. However, when I run the code, I get this error.
Expected: Array
Shouldn't the Split function have already made it an array? What corrections do I need to make to get this to work right?