Hey time a call to stop the spindle has a decel curve involved, so you need a while is moving call to wait for the decel to happen before moving on in your script.
Try this:
DoSpinStop() 'stop spindle
While Ismoving()
Sleep 50
Wend
Code "M421" 'unblock wp selection buttons
While Ismoving()
Sleep 50
Wend
this will give the spindle decel time a chance to move to zero before the VB executes down further. On motion code, it is sometimes best to put a whild ismoving after each call.
If that doest work for you, then "Repeat" the DoSpinStop call with the while is moving as the next block of code below the first one.
scott
Commercial Mach3: Screens, Wizards, Plugins, Brains,PLCs, Macros, ATC's, machine design/build, retrofit, EMC2, Prototyping. http://sites.google.com/site/volunteerfablab/