The basic problem you are probably having is that you aren't checking every character: a
For
loop automatically increments the variable, so when you don't find a match you skip a character automatically. Removing your whole
Else
clause will probably fix that, but that is a poor way to do things.
I would rename your variables:
chk
becomes
lastChar
and I would set it to a silly value to start with.
I would then use a
For Each
loop to extract each character in turn:
Dim str As String = "hello paul"
Dim lastChar As Char = ControlChars.Lf
For Each thisChar As Char In str
If thisChar = lastChar Then
End If
lastChar = thisChar
Next