'************************************** ' Name: Incremental Turn Key ' Description:Set of functions that have ' a ordinal odd even and numerical increme ' ntal and/or decremented counter describe ' d in it that is able changed with the fu ' nctions and returned. ' By: Nicholas Forystek ' ' ' Inputs:None ' ' Returns:None ' 'Assumes:None ' 'Side Effects:None '************************************** Public Sub Main() Dim K As Long IncKeyVal K Debug.Print "Keyval: " & KeyVal(K) TrnKey K Debug.Print "KeyDsc: " & KeyDsc(K) TrnKey K Debug.Print "Keyval: " & KeyDsc(K) IncKeyVal K Debug.Print "Keyval: " & KeyVal(K) IncKeyVal K Debug.Print "Keyval: " & KeyVal(K) TrnKey K Debug.Print "KeyDsc: " & KeyDsc(K) IncKeyVal K Debug.Print "Keyval: " & KeyVal(K) DecKeyVal K Debug.Print "Keyval: " & KeyVal(K) TrnKey K Debug.Print "KeyDsc: " & KeyDsc(K) DecKeyVal K Debug.Print "Keyval: " & KeyVal(K) TrnKey K Debug.Print "KeyDsc: " & KeyDsc(K) DecKeyVal K Debug.Print "Keyval: " & KeyVal(K) DecKeyVal K Debug.Print "Keyval: " & KeyVal(K) End Sub Sub TrnKey(ByRef K As Long) ' _ Turn the sequence ordinal value held with-in to the next in sequence. K = -K If K Mod 4 = 0 Then K = -K - -4 If K Mod 4 > 0 Then K = K - -2 If K Mod 2 > 0 Then K = K + 1 K = -K If K Mod 2 = 0 Then K = -K - 4 If K Mod 4 < 0 Then K = K + 1 If K Mod 2 < 0 Then K = -K + -2 K = -K End Sub Function KeyDsc(ByRef K As Long) As Long ' _ Return the key description, a sequence ordinal value changed by TrniKey KeyDsc = (Abs(K) - (Abs(K) + 1)) * IIf(K > 0, 1, -1) End Function Function KeyVal(ByRef K As Long) As Long ' _ Return the key value, a counter with-in K KeyVal = Abs((Abs(K) + 1) \ 4) End Function Sub IncKeyVal(ByRef K As Long) ' _ Increment Key Value, a counter with-in K K = (-1 + Abs(K) + 3 + ((K Mod 4) + 2)) * IIf(K < 0, 1, -1) End Sub Sub DecKeyVal(ByRef K As Long) ' _ Decrement Key Value, a counter with-in K K = (1 + Abs(K) - 3 + (K Mod 4) - 2) * IIf(K > 0, 1, -1) End Sub