[AccessD] [Spam] Left and right shift

Jim Dettman jimdettman at verizon.net
Wed Apr 7 10:16:14 CDT 2010


FYI,

  Here's a couple routines I found to do bit shifts in VBA:


Public Function shr(ByVal Value As Long, ByVal Shift As Byte) As Long
    Dim i As Byte
    shr = Value
    If Shift > 0 Then
        shr = Int(shr / (2 ^ Shift))
    End If
End Function

Public Function shl(ByVal Value As Long, ByVal Shift As Byte) As Long
    shl = Value
    If Shift > 0 Then
        Dim i As Byte
        Dim m As Long
        For i = 1 To Shift
            m = shl And &H40000000
            shl = (shl And &H3FFFFFFF) * 2
            If m <> 0 Then
                shl = shl Or &H80000000
            End If
        Next i
    End If
End Function

Jim.

-----Original Message-----
From: accessd-bounces at databaseadvisors.com
[mailto:accessd-bounces at databaseadvisors.com] On Behalf Of jwcolby
Sent: Wednesday, April 07, 2010 9:56 AM
To: Access Developers discussion and problem solving
Subject: [Spam] [AccessD] Left and right shift

I thought we have a >> and << operator in Access - shift left and shift
right.  When I try to use it 
I get a compile error.

   IntPtr = IntPtr >> 2

Do we not have this operator?  I can't find it listed in an operator in
help.

-- 
John W. Colby
www.ColbyConsulting.com
-- 
AccessD mailing list
AccessD at databaseadvisors.com
http://databaseadvisors.com/mailman/listinfo/accessd
Website: http://www.databaseadvisors.com




More information about the AccessD mailing list