Hi Henrik and Richard.

Many thanks for your prompt reply.

Really i'm not comfortable with programming, and i try to do what i really understand.

I think i solve the issue by changing the following lines to these.....

Code:
chkey:
if  portb.0 = 1 and portb.1 = 0 and portb.2 = 0 and portb.3 = 0 and portb.4 = 0 then return
if  portb.0 = 1 and portb.1 = 1 and portb.2 = 0 and portb.3 = 0 and portb.4 = 0 then return
if  portb.0 = 1 and portb.1 = 1 and portb.2 = 1 and portb.3 = 0 and portb.4 = 0 then return
if  portb.0 = 1 and portb.1 = 1 and portb.2 = 1 and portb.3 = 1 and portb.4 = 0 then return  
if  portb.0 = 1 and portb.1 = 1 and portb.2 = 1 and portb.3 = 1 and portb.4 = 1 then pwok
I wish i could manage to learn how to store values and read them after. I know that the code is not efficient at all.

for now it works. I also change all the PORTX to LATX.

In the mean time i will try to learn and understand how to right values, then store them, read them and compare.

Many thanks once again.