Help with code

What have you found by debugging like I suggested above?

If you post a code snippet, ALWAYS USE CODE TAGS:

How to use code tags: Using code tags properly