FYI: One of the reasons your code fails is this line: y = Mid(Text1.Text, x, 1)
How can y = "ng" if the Mid() function is only returning 1 character?