发表于:2008-08-06 15:14:10
楼主
Public Function GET_BIT(DecimalValue As Long, bitN As Long) As Long '取位
Dim land As Long
land = 2 ^ bitN
GET_BIT = (DecimalValue And land) / land
End Function
Public Function SET_BIT(DecimalValue As Long, bitN As Long) As Long '置位
Dim land As Long
land = 2 ^ bitN
If GET_BIT(DecimalValue, bitN) = 0 Then
SET_BIT = DecimalValue + land
Else: SET_BIT = DecimalValue
End If
End Function
Public Function RESET_BIT(DecimalValue As Long, bitN As Long) As Long '复位
Dim land As Long
land = 2 ^ bitN
If GET_BIT(DecimalValue, bitN) = 1 Then
RESET_BIT = DecimalValue - land
Else: RESET_BIT = DecimalValue
End If
End Function
Public Function CHANGE_BIT(DecimalValue As Long, bitN As Long) As Long '复位
Dim land As Long
land = 2 ^ bitN
If GET_BIT(DecimalValue, bitN) = 1 Then
CHANGE_BIT = DecimalValue - land
Else: RESET_BIT = DecimalValue + land
End If
End Function