Trusting God in the Hard Times

How can I hold on to my faith in God when things go wrong? As a Christian, I know that I'm supposed to "give thanks in all things" and look to the Lord for my daily needs. Yet I've been through some devastating experiences over the past year. How can I be thankful and trust God at a time like this?