Visual Basic does not provide any native methods for performing bitwise manipulation, nor does it provide unsigned data types. This module offers routines for bit shifting, bit setting, clearing bits, unsigned assignment operations, and extracting components of variables.

Procedure Name | Type | Description |

(Declarations) | Declarations | Declarations and private variables for the modBitOps module. |

BitClearByte | Procedure | Clear a bit in a byte variable. |

BitClearInteger | Procedure | Clear a bit in an integer variable. |

BitClearLong | Procedure | Clear a bit in a long variable. |

BitSetByte | Procedure | Set a bit in a byte variable. |

BitSetInteger | Procedure | Set a bit in an integer variable. |

BitSetLong | Procedure | Set a bit in a long variable. |

BitTestByte | Procedure | Test a bit in a byte to see if it is turned on. |

BitTestInteger | Procedure | Test a bit in an integer to see if it is turned on. |

BitTestLong | Procedure | Test a bit in a long integer to see if it is turned on. |

dblToLong | Procedure | Perform an unsigned conversion from a double value to a long value. Handles doubles greater than 2,147,483,647 and less than or equal to 4,294,967,295. |

HiByte | Procedure | Get the high byte of an integer. |

HiLong | Procedure | Get the high long of a double. |

HiWord | Procedure | Get the high integer of a long integer. |

IntToByte | Procedure | Perform an unsigned conversion from an integer value to a byte value. This procedure correctly handles any integer value. For example, lngNumber = -1 assigns -1 to the variable lngNumber. However, lngNumber = IntToLong(-1) assigns 65,535 to lngNumber. |

IntToLong | Procedure | Convert an integer value to a long value, treating the integer as unsigned. For example, performing lngNumber = -1, assigns -1 to the variable. However, performing lngNumber = IntToLong(-1) assigns 65,535. |

LoByte | Procedure | Get the low byte of an integer. |

LoLong | Procedure | Get the low long of a double. |

LongToDbl | Procedure | This routine converts a long value to a double value, treating the long as unsigned. For example, performing dblNumber = -1, assigns -1 to the variable dblNumber. However, dblNumber = LongToDbl(-1), assigns 4,294,967,295. |

LongToInt | Procedure | Perform an unsigned conversion from a long value to an integer value. |

LoWord | Procedure | Get the low integer of the passed long. |

MakeDbl | Procedure | Combine two longs into a double while handling negative values. |

MakeInt | Procedure | Combine two bytes into an integer. |

MakeLong | Procedure | Combine two words (integers) into a long while handling negative values. |

Shlb | Procedure | Shift a byte value left by the specified number of bits. Left shifting is a multiplication operation. For the number of bits to shift to the left, raise two to that power, then multiply the result by the original value. |

Shli | Procedure | Shift an integer value left by the specified number of bits. Left shifting is a multiplication operation. For the number of bits to shift to the left, raise two to that power, then multiply the result by the original value. |

Shll | Procedure | Shift a long integer value left by the specified number of bits. Left shifting is a multiplication operation. For the number of bits to shift to the left, raise two to that power, then multiply the result by the original value. |

Shrb | Procedure | Shift a byte value right the selected number of places. Right shifting is a division operation. For the number of bits to shift to the right, raise two to that power, then divide the original value by the result. |

Shri | Procedure | Shift an integer value right the selected number of places. Right shifting is a division operation. For the number of bits to shift to the right, raise two to that power, then divide the original value by the result. |

Shrl | Procedure | Shift a long integer value right the selected number of places. Right shifting can be defined as a division operation. For the number of bits to shift a value to the right, raise two to that power, then divide our original value by the result. |

The source code in Total Visual Sourcebook includes modules and classes for Microsoft Access, Visual Basic 6 (VB6), and Visual Basic for Applications (VBA) developers. Easily add this professionally written, tested, and documented royalty-free code into your applications to simplify your application development efforts.

Total Visual SourceBook is written for the needs of a developer using a source code library covering the many challenges you face. Countless developers over the years have told us they learned some or much of their development skills and tricks from our code. You can too!

is Shipping!

Supports Access/Office 2016, 2013, 2010 and 2007, and Visual Basic 6.0!

"The code is exactly how I would like to write code and the algorithms used are very efficient and well-documented."

Van T. Dinh, Microsoft MVP