'************************************** ' Name: Invert Signed Numerical ' Description:This is a invert function ' that, I am unsure is 100% accurate, but ' appears for the lower memory definitions ' of integer as such that it is inverting, ' however the whole basis container is con ' siderably the incremental signed value o ' f the unsigned input. ' By: Nicholas Forystek ' ' ' Inputs:None ' ' Returns:None ' 'Assumes:None ' 'Side Effects:None '************************************** Public Function Invert(ByVal Value As Variant, Optional ByVal Whole As Variant = Empty) As Variant ' _ Inverts the Value based ona Whole, unspecified integers invert in 32767 and longs in 2147483647, and, Invert(25, 100)=75 If TypeName(Whole) = "Empty" Then Select Case TypeName(Value) Case "Byte" Value = -1 - CDbl(CDbl(-CDbl(125) + -(CDbl(Value) - 1) + CDbl(CDbl(125) * CDbl(2)))) Case "Integer", "Boolean" Value = -1 - CDbl(CDbl(-CDbl(32677) + -(CDbl(Value) - 1) + CDbl(CDbl(32677) * CDbl(2)))) Case "Long", "Single" Value = -1 - CDbl(CDbl(-CDbl(1073741824) + -(CDbl(Value) - 1) + CDbl(CDbl(1073741824) * CDbl(2)))) Case "Double", "Currency" Value = -1 - CDbl(CDbl(-CDbl(125) + -(CDbl(Value) - 1) + CDbl(CDbl(125) * CDbl(2147483645)))) Case Else Value = -125 - CDbl(CDbl(-CDbl(32765) + -(CDbl(Value) - 125) + CDbl(CDbl(32765) * CDbl(2147483645)))) End Select Else Value = CDbl(-CDbl(Whole) + -CDbl(Value)) + CDbl(CDbl(Whole) * CDbl(2)) End If Invert = Value End Function