VB icon

Incremental Turn Key

Email
Submitted on: 2/12/2019 5:10:13 AM
By: Nicholas Forystek  
Level: Beginner
User Rating: Unrated
Compatibility: VB 6.0
Views: 377
author picture
 
     Set of functions that have a ordinal odd even and numerical incremental and/or decremented counter described in it that is able changed with the functions and returned.
 
code:
Can't Copy and Paste this?
Click here for a copy-and-paste friendly version of this code!
				
'**************************************
' Name: Incremental Turn Key
' Description:Set of functions that have a ordinal odd even and numerical incremental and/or decremented counter described in it that is able changed with the functions and returned.
' By: Nicholas Forystek
'**************************************

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


Other 21 submission(s) by this author

 


Report Bad Submission
Use this form to tell us if this entry should be deleted (i.e contains no code, is a virus, etc.).
This submission should be removed because:

Your Vote

What do you think of this code (in the Beginner category)?
(The code with your highest vote will win this month's coding contest!)
Excellent  Good  Average  Below Average  Poor (See voting log ...)
 

Other User Comments


 There are no comments on this submission.
 

Add Your Feedback
Your feedback will be posted below and an email sent to the author. Please remember that the author was kind enough to share this with you, so any criticisms must be stated politely, or they will be deleted. (For feedback not related to this particular code, please click here instead.)
 

To post feedback, first please login.