why first 2 msgboxes work and the third is inactive here?

Hello!
Please, can someone find the reason why is the third msgbox not working here, while first two do wrok ok?

Many thanks!!!

function z


dim a as string

 a=inputbox("MMM", "XX")
 msgbox(a, "mmm,", "ddd")
                             dim d as integer
                             d=len(a)
                             msgbox(d,0,"steve")

                                      Do While d=1
                                                  dim m as string
                                                  m=mid(a,d,1)
                                                  msgbox(m, 0,"d")       '*** The one which 
                                                  d=d-1                  ' does not work
                                         Loop                            ' and I dont know why

end function

Is maybe the problem cause it is IN Do While Loop???

Many thanks!!!

Just solved!!!
Thanks all!