deleted repeated characters

Hi guys,I need help with deleting repeated characters in a string
for example if the user inputs aab the returned string will be ab
I am using visual studio
i have this code so far but i am not getting a returned string.

1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
  Public Class Form1

    Private Function CleanString(ByVal strng As String)
        If strng.Length = 0 Then
            Return strng
        End If

        Dim a As Char = GetChar(strng, strng.Length - 1)
        Dim b As String = strng.Substring(0, strng.Length - 1)

        If b.IndexOf(a) > -1 Then
            Return CleanString(b)
        Else
            Return CleanString(b) And CleanString(a)
        End If
    End Function

    Private Function GetChar(ByVal strng As String, ByVal index As Integer) As String
        Dim chars() As Char = strng.ToCharArray()

        Return chars(index)
    End Function


 Private Sub btnEval_Click(sender As Object, e As EventArgs) Handles btnEval.Click
        Dim c As Char = txtInput.Text
        txtOutput.Text = CleanString(c)
    End Sub

   
End Class
Topic archived. No new replies allowed.