Please post the relevant portion of the code you are using and what areas in the code you think are generating the problem. We cannot divine what of any possible billion combinations of code could return a -1. This is not even to say that we might be able to help, it's just that with what you have given us, none of us will be able to help you. You may also want to read
How To Ask Questions The Smart Way, which is not meant as a knock at you, but rather a suggestion about how you can be better recieved.
Perhaps your veeblefritzer is clogged.