Thank you Ligo for your reply.
It is working fine on port d. After I removed the return from the example code.
Feel a bit silly now. I have the PICkit 2 connected to port b, so it would not work at the same time as I was debugging it.
Kind regards
Bob.