Public Class Form1
    Dim nr_vocale As Integer
    Dim vocale() As String = {"a", "e", "i", "o", "u"}
    Dim poz As Integer
    Dim mouse As Integer
    Dim temp As String
    Dim var As Integer = 5

    Private Sub RichTextBox1_TextChanged_1(ByVal sender As System.Object, ByVal e As System.EventArgs) Handles RichTextBox1.TextChanged
        mouse = RichTextBox1.SelectionStart
        RichTextBox1.SelectionColor = Color.Black
        nr_vocale = 0
        poz = 1
        'textul = RichTextBox1.Text
        For j = 0 To 4
            poz = InStr(poz, RichTextBox1.Text.ToLower, vocale(j))
            While poz > 0
                nr_vocale += 1
                RichTextBox1.SelectionStart = poz - 1
                RichTextBox1.SelectionLength = 1
                RichTextBox1.SelectionColor = Color.Red
                poz = InStr(poz + 1, RichTextBox1.Text.ToLower, vocale(j))
            End While
            If poz = 0 Then
                poz = 1
            End If
        Next
        Label1.Text = Str(nr_vocale)

        var = 5
        temp = RichTextBox1.Text(mouse - 1)
        For j = 0 To 4
            If temp.ToLower = vocale(j) Then
                var = 0
            End If
        Next
        If var <> 0 Then
            RichTextBox1.SelectionStart = mouse - 1
            RichTextBox1.SelectionLength = 1
            RichTextBox1.SelectionColor = Color.Black
        End If

        RichTextBox1.SelectionStart = mouse
        RichTextBox1.SelectionLength = 0
        RichTextBox1.SelectionColor = Color.Black
    End Sub

End Class
