I like the idea mentioned several times already of setting "way marks" as you climb.
When I first started riding I would pick a sign, telephone pole or what have you and aim for that. When I made it that far up the hill, without collapsing into the ditch, I would add the next item as my new goal.
I remember one stretch of a particularly bad hill where I was counting beer cans in the weeds.
"I can make it to the Bud Light can, today - I know I can!"