Hi,
OK, if I get this right it should be enough to remember the previous state of the input.

FWD: 0,1,3,7,15,31,63,62,60,56,48,32
REV: 0,32,48,56,60,62,63,31,15,7,3,1

If the current state is 15 and the previous state is 7 we're going forward, if the current state is 15 and the previous state is 31 we're going backwards.
Code:
EncoderState = PortA
If EncoderState <> OldState THEN  ' Don't run commutation code if shaft hasn't moved. 
 
Select Case EncoderState
 
Case 0
  If OldState = 32 THEN  'We're moving FWD
  'Code for FWD
  ELSE
  'Code foe REV
  ENDIF

Case 1
  If OldState = 0 THEN   'We're moving forward
  'Code for FWD
  ELSE
  'Code for REV
  ENDIF
 
Case 3
  If OldState = 1 THEN   'We're moving forward
  'Code for FWD
  ELSE
  'Code for REV
  ENDIF
 
' And so on for all twelve states.
 
OldState = EncoderState  'Remember current state.
ENDIF
As for the switch, I just mean that if you don't think it's enough to check at the beginning of the loop you'll have to check it as often as you think is neccessary, for example in each case statement. Personally I think that it's enought to check it one time in the main loop since only one of the Case blocks will get executed anyway. But I may have missed something.