msgbox(m...), m= mid(...)

Hello!
I had such a code:

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")
             d=d-1
             Loop

end function

Please, I want the function to write in a loop all letters written in the inputbox, counting from the end to beginning.
F.e., I write in the inputnox : dream, and want the loop to write out:

m
a
e
r
d

of course, in the msgbox. So, why is that not working?
Thanks for any help!

Please state clear questions that relate to LibreOffice, instead of asking “why is this code not working” when the code does not look like it should do what you want. Make sure the main question is a question. Thanks.