Sono riuscito a scrivere questo piccolo programmino che mi cambia il colore del testo a seconda dei parametri inseriti e funziona bene:
For CONTA = contatore To lunghezza - 1 Step 1
If X(CONTA) = "N" Then
K = "N"
COLORE = Color.Gray
End If
If X(CONTA) = "X" Then
K = "X"
COLORE = Color.Blue
End If
If X(CONTA) = "Y" Then
K = "Y"
COLORE = Color.Red
End If
If X(CONTA) = "Z" Then
K = "Z"
COLORE = Color.Maroon
End If
If X(CONTA) = "S" Then
K = "S"
COLORE = Color.Blue
End If
If X(CONTA) = "T" Then
K = "T"
COLORE = Color.White
End If
If X(CONTA) = "M" Then
K = "M"
COLORE = Color.Brown
End If
If X(CONTA) = "G" Then
K = "G"
COLORE = Color.White
End If
If X(CONTA) = "F" Then
K = "F"
COLORE = Color.Orange
End If
Select Case X(CONTA)
Case K
Select Case X(CONTA + 1)
'PRIMA CIFRA
Case "1", "2", "3", "4", "5", "6", "7", "8", "9", "0", "-", "."
RichTextBox1.Select(CONTA, "12".Length)
RichTextBox1.Focus()
RichTextBox1.SelectionColor = COLORE
RichTextBox1.Select(RichTextBox1.Text.Length, 0)
'SECONDA CIFRA
Select Case X(CONTA + 2)
Case "1", "2", "3", "4", "5", "6", "7", "8", "9", "0", "-", "."
RichTextBox1.Select(CONTA, "123".Length)
RichTextBox1.Focus()
RichTextBox1.SelectionColor = COLORE
RichTextBox1.Select(RichTextBox1.Text.Length, 0)
Select Case X(CONTA + 3)
Case "1", "2", "3", "4", "5", "6", "7", "8", "9", "0", "-", "."
RichTextBox1.Select(CONTA, "1234".Length)
RichTextBox1.Focus()
RichTextBox1.SelectionColor = COLORE
RichTextBox1.Select(RichTextBox1.Text.Length, 0)
Select Case X(CONTA + 4)
Case "1", "2", "3", "4", "5", "6", "7", "8", "9", "0", "-", "."
RichTextBox1.Select(CONTA, "12345".Length)
RichTextBox1.Focus()
RichTextBox1.SelectionColor = COLORE
RichTextBox1.Select(RichTextBox1.Text.Length, 0)
Select Case X(CONTA + 5)
Case "1", "2", "3", "4", "5", "6", "7", "8", "9", "0", "-", "."
RichTextBox1.Select(CONTA, "123456".Length)
RichTextBox1.Focus()
RichTextBox1.SelectionColor = COLORE
RichTextBox1.Select(RichTextBox1.Text.Length, 0)
Select Case X(CONTA + 6)
Case "1", "2", "3", "4", "5", "6", "7", "8", "9", "0", "-", "."
RichTextBox1.Select(CONTA, "1234567".Length)
RichTextBox1.Focus()
RichTextBox1.SelectionColor = COLORE
RichTextBox1.Select(RichTextBox1.Text.Length, 0)
Select Case X(CONTA + 7)
Case "1", "2", "3", "4", "5", "6", "7", "8", "9", "0", "-", "."
RichTextBox1.Select(CONTA, "12345678".Length)
RichTextBox1.Focus()
RichTextBox1.SelectionColor = COLORE
RichTextBox1.Select(RichTextBox1.Text.Length, 0)
Select Case X(CONTA + 8)
Case "1", "2", "3", "4", "5", "6", "7", "8", "9", "0", "-", "."
RichTextBox1.Select(CONTA, "123456789".Length)
RichTextBox1.Focus()
RichTextBox1.SelectionColor = COLORE
RichTextBox1.Select(RichTextBox1.Text.Length, 0)
Select Case X(CONTA + 9)
Case "1", "2", "3", "4", "5", "6", "7", "8", "9", "0", "-", "."
RichTextBox1.Select(CONTA, "1234567890".Length)
RichTextBox1.Focus()
RichTextBox1.SelectionColor = COLORE
RichTextBox1.Select(RichTextBox1.Text.Length, 0)
Select Case X(CONTA + 10)
Case "1", "2", "3", "4", "5", "6", "7", "8", "9", "0", "-", "."
RichTextBox1.Select(CONTA, "12345678901".Length)
RichTextBox1.Focus()
RichTextBox1.SelectionColor = COLORE
RichTextBox1.Select(RichTextBox1.Text.Length, 0)
Select Case X(CONTA + 11)
Case "1", "2", "3", "4", "5", "6", "7", "8", "9", "0", "-", "."
RichTextBox1.Select(CONTA, "123456789012".Length)
RichTextBox1.Focus()
RichTextBox1.SelectionColor = COLORE
RichTextBox1.Select(RichTextBox1.Text.Length, 0)
Select Case X(CONTA + 12)
Case "1", "2", "3", "4", "5", "6", "7", "8", "9", "0", "-", "."
RichTextBox1.Select(CONTA, "1234567890123".Length)
RichTextBox1.Focus()
RichTextBox1.SelectionColor = COLORE
RichTextBox1.Select(RichTextBox1.Text.Length, 0)
End Select
End Select
End Select
End Select
End Select
End Select
End Select
End Select
End Select
End Select
End Select
End Select
End Select
quello che non riesco a fare sono le eccezioni.
mi spiego meglio:
vorrei che se mettessi un testo nelle parentesi() esso dia sempre di un colore definito,tipo verde,anche le parentesi dello stesso colore. come posso implementare il codice?
ringrazio in anticipo chi volesse dare un aiutino.