VB6位运算

  1. '位左移  
  2. Public Function SHL(nSource As Long, n As Byte) As Long  
  3.     SHL = nSource * 2 ^ n  
  4. End Function  
  5.   
  6. '位右移  
  7. Public Function SHR(nSource As Long, n As Byte) As Long  
  8.     SHR = nSource / 2 ^ n  
  9. End Function  
  10.   
  11. '获得指定的位  
  12. Public Function GetBits(nSource As Long, n As Byte) As Boolean  
  13.     GetBits = nSource And 2 ^ n  
  14. End Function  
  15.   
  16. '设置指定的位  
  17. Public Function SetBits(nSource As Long, n As Byte) As Long  
  18.     SetBits = nSource Or 2 ^ n  
  19. End Function  
  20.   
  21. '清除指定的位  
  22. Public Function ResetBits(nSource As Long, n As Byte) As Long  
  23.     ResetBits = nSource And Not 2 ^ n  
  24. End Function  
原文地址:https://www.cnblogs.com/xbj-hyml/p/6689705.html