replace
Code:
For i = 1 To Len(b)
with
Code:
For i = 1 To b