1 - Please post your code, so what you describe can be reproduced.
2 - You should avoid MsgBox. It changes the focus, which may affect the results. You should instead use System.DebugLog. http://documentation.xojo.com/index.php/System.debuglog
@Michel Bujardet , I think you were right about the MsgBox messing things up. I replaced it with the System.DebugLog call, and the problem seems to have gone away.
Thank you!