Hi,

I would do one of two things:

1) Learn to use your debugger. That way you can watch what is happening to all the variables as you step through your program.

2) Do it the old fashioned way: get a piece of paper and write all your variable names across the top of the page. Then go through your function and write down the new values for the variables as they change until you see what's going wrong.