CX should be 0 to LEN(N$)-1. However, your lines 59 and 63 allow CX to be -1 to LEN(N$).