Hi,
For that you need to use the Analog to Digital converter available in most PICs (but not all). It CAN be done with the comparators too by generating the VRef voltage with for example PWM and then sweeping the voltage from zero upwards while watching the comparator output. When the comparator output toggles you know the voltage. But the ADC is easier though....

Which PIC are you using?