Function GetBit(ByVal SourceNumber As Long, ByVal BitNo As Byte) As Byte
GetBit = (SourceNumber And (2 ^ (BitNo - 1))) \ (2 ^ (BitNo - 1))
End Function
说明:
SourceNumber:原32位长整数
BitNo:从右算起第几位
返回值为长整数从右开始某一位的值
32位整数吧,简单,现场写个函数给你:
Public Function GetBit(Byval SourceNumber as long , Byval BitNo as byte ) as byte
for BitNo =BitNo to BitNo-1 step -1
SourceNumber =SourceNumber \2
GetBit= SourceNumber Mod 2
next
End Function
说明:
SourceNumber :原32位长整数
BitNo :从右算起第几位
返回值为长整数从右开始某一位的值