In fact it is crazy ... or not. You want to set a specific I/O to use ONLY what you want to. Sure we read analog thing... but with the comparator.. not the ADC... ANSEL & ANSELH set a pin as analog to use with tthe internal ADC... kinda thing to understand/remember.

I realized the opposite of what is written in the data sheet. (may be because it's in English ?)
Fais-toi en pas avec ça... avec un peu de pratique, le tout deviendra plus clair

I have a question to ask you. What is "LATB.6" ? (This is true for any LAT(PORT number)?
LATx is the output PORT Latch. Usually with PIC18 (and all other PIC with LATx register) you want to write to LATx, but read from PORTx. In THIS specific case, you shouldn't experiment any problem if you use PORTB.6, but it's something to keep in mind.

On apprends les bonne habitudes en premier