you don't need any while isMovings, sleeps or variables for what you're doing. If all you want to do is increment a DRO with each call to the macro ALL you need is the single line
SetUserDRO(1010, GetUserDRO(1010)+1)
Type it into the vb editor and try it - THEN make sure you save it correctly and in the right place. If you do that it will run from the MDI AND from GCode.
Ian