Code:
iF PORTB.1=0 then
    HIGH PORTB.5
    WHILE PORTB.0=0 : Wend : pause 50
    ENDIF
Why not use Toggle ?
Code:
IF PORTB.1=0 then
    toggle PORTB.5
    WHILE PORTB.0=0 : Wend : pause 50
    ENDIF
Do not know what you are doing with PORTB.0 or why it is always low in each
if then loop . . . or is that a copy paste error, and is low only in the first loop ?
maybe should be PortB.1 in this loop ? Select case could tidy this up even more . . .