Search Tools Links Login

CMultiBits Class


CMultiBits is a class, with no dependencies, that handles bit manipulation in Byte, Integer, Long, Single, Double, Currency, Dates, and Long Arrays. (These are VarTypes 2 thru 7, 17 and 8195. The Long Arrays are in place of Decimals but can be expanded way beyond Decimal size. It should be noted that the class can only handle one dimensional long arrays.)

Features

CMultiBits manipulates bits (including the sign bit) in all the above data types. It allows creating bitfields of any size from 8 bits (Byte) to 64 bits (Currency, Dates or Doubles), or up to unlimited size using a long array acting as a single bit field. (You can even do bit shifting and rotating on a long array and it will act as if it were a single bitfield.) And all of these variables (including long arrays) all use the same public interface.

Another feature is the ability to store numeric values within a bitfield, right along with boolean values, making for what might be called a 'hybrid bitfield.'

The class features the option to use typecasting for strings, Singles, 64 bit data types and long arrays. It also makes use of VB's hidden GetMem and PutMem methods. (Typecasting was adapted from a Bonnie West class - many thanks.) There are also a number of optional parameters that allow some flexibility in the class.

The class also has a complete collection of Byte/Integer/Long /Currency Combo & Extraction routines, as well has bit/hex string read & write routines.

Copious notes are included to help understand the code.

Interface

For bit manipulation:

CustomValue (property get/let) is for inserting & extracting numeric values from bit fields. IsFlagged reads one bit or multiple bits.

The combo/extract routines include:

About this post

Posted: 2019-12-17
By: RobertDee
Viewed: 271 times

Categories

Visual Basic 6

Attachments

CMultiBits.zip
Posted: 12/17/2019 6:32:02 AM
Size: 30,154 bytes


Loading Comments ...

Comments

No comments have been added for this post.

You must be logged in to make a comment.