Darned Code!
Sometimes I will be looking at some code trying to figure out where it is giving an error message - I know I will find it, but just not at that moment and sometimes it can be frustrating. So, if I can, I will sleep it over and then in the morning I tackle it and the answer comes right away. What do you do when you just can't figure it out at the moment?
I usually do something similar to that. When I am working on a program for hours and can't figure out why something is not working right, I usually have to step away from it for a while and focus on something else. This gives me a fresh perspective to the issue when I return to work on it.