VBcoders Guest



Don't have an account yet? Register
 


Forgot Password?



CMultiBits

by Robert Dee (2 Submissions)
Category: Custom Controls/Forms/Menus
Compatability: VB 6.0
Difficulty: Advanced
Originally Published: Mon 13th March 2017
Date Added: Tue 9th February 2021
Rating: (1 Votes)

CMultiBits[UpdatedMarch12,2017]PURPOSE:CMultiBitsisaclass,withnodependencies,thathandlesbitmanipulationinByte,Integer,Long,Single,Double,Currency,Dates,andLongArrays.(TheseareVarTypes2thru7,17and8195.TheLongArraysareinplaceofDecimalsbutcanbeexpandedwaybeyondDecimalsize.Itshouldbenotedthattheclasscanonlyhandleonedimensionallongarrays.)FEATURES:CMultiBitsmanipulatesbits(includingthesignbit)inalltheabovedatatypes.Itallowscreatingbitfieldsofanysizefrom8bits(Byte)to64bits(Currency,DatesorDoubles),oruptounlimitedsizeusingalongarrayactingasasinglebitfield.(Youcanevendobitshiftingandrotatingonalongarrayanditwillactasifitwereasinglebitfield.)Andallofthesevariables(includinglongarrays)allusethesamepublicinterface.Anotherfeatureistheabilitytostorenumericvalueswithinabitfield,rightalongwithbooleanvalues,makingforwhatmightbecalleda'hybridbitfield.'Theclassfeaturestheoptiontousetypecastingforstrings,Singles,64bitdatatypesandlongarrays.ItalsomakesuseofVB'shiddenGetMemandPutMemmethods.(TypecastingwasadaptedfromaBonnieWestclass-manythanks.)Therearealsoanumberofoptionalparametersthatallowsomeflexibilityintheclass.TheclassalsohasacompletecollectionofByte/Integer/Long/CurrencyCombo&Extractionroutines,aswellhasbit/hexstringread&writeroutines.Copiousnotesareincludedtohelpunderstandthecode.INTERFACE:Forbitmanipulation:SetBitFlag/ClearBitFlag(single&multiplebits),Toggle,Shift,Rotate,ReverseBits,ReverseBytes,CountBits,Bit/Hexstringcreating&reading.CustomValue(propertyget/let)isforinserting&extractingnumericvaluesfrombitfields.IsFlaggedreadsonebitormultiplebits.Thecombo/extractroutinesinclude:LoNibble/HiNibble/MakeByte(Extract/combinenibbles.)LoByte/HiByte/MakeWord(Extract/combinebytes.)LoWord/HiWord/MakeDWord(Extract/combineintegers.)LoDWord/HiDWord/MakeQWord(Extract/combinelongs.)LongFromBytes(Combine1to4bytestoformalong.)ByteFromLong(Extractanybytefromalong.)ByteIntoLong(Insertabyteintoanypositionofanexistinglong.)ByteFromCurr(Extractanybytefromcurrency)ByteIntoCurr(Insertbyteintoanybytepositionofcurrency.IntFromCurr(Extractanyintegerfromacurrency),IntIntoCurr(Insertanintegerintoanyintpositionofacurrency)UPDATES:3/12/17:Updatesincludeallthedebugstatementssothattheynowproperlyshow"Module.Method:Information..."Therewerealsojustacoupleofsmallrefinementsinafewplacesinthecode.Andmanyoftheremarkswereupdatedtoreflecttheimprovedcapabilitiesinthelastcoupleofupdates.Therearenochangestothepublicinterface.Soanyexistingcodethatusesthisclasswillcontinuetoworkas-is.Anyimprovements,ideasorbugreportswouldbemuchappreciated.Seejustabove"OptionExplicit"foracompletelistingoffeaturesandimprovementhistory.Incidentally,theinterfacewillalsohandlealongarraycontainedwithinaUDT.Itwilltreatitthesameasanormallydimensionedlongarray.

Rate CMultiBits

Download CMultiBits

Download CMultiBits (31 KB)

CMultiBits Comments

No comments have been posted about CMultiBits. Why not be the first to post a comment about CMultiBits.

Post your comment

Subject:
Message:
0/1000 characters