every cloud has a silver lining
Every trouble has something hopeful that you can see in it, like the bright edge around a dark cloud. — A proverb.
The doctor told Tommy to cheer up when he had measles. "Every cloud has a silver lining," he said.
Compare: IT'S AN ILL WIND THAT BLOWS NOBODY GOOD.