<-- Previous || Up || Next -->

Set Bit Function
Bitwise Class

Public Function SetBit( _
      ByVal vVariant As Variant _
    , ByVal vBit As Variant _
    , ByVal vValue As Variant _
    ) As Variant

Set a bit within any type of value.
Returns the argument unchanged if the bit to be set is not within range.
Bits range from 1 (one is the least-significant-bit) to the number of bits in the value.

    SetBit( 0, 5, 1) = 16
    SetBit(31, 2, 0) = 29
    SetBit(Chr$(255) + Chr$(255), 3, 0) = Chr$(255) + Chr$(251)
    SetBit(Chr$(0) + Chr$(0), 3, 1) = Chr$(0) + Chr$(4)
See also:
    GetBit Function
    SetBitInStringFast Function
vVariant: Value in which one of the bits is to be set to either True or False. Function returns Null if vVariant is Null.

vBit: The number of the bit whose value within variable vValue is to be changed. Function returns Null if vBit is Null or cannot be fixed up to a number. vBit 1 (one) is the most-significant-bit within Strings and the least-significant-bit within numbers.

Function returns vVariant unchanged if vBit is <= 0 (less than or equal to zero).

vValue: The value to which the specified bit will be set. Function returns Null if vValue is Null or cannot be fixed up to a number.

Copyright 1996-1999 Entisoft
Entisoft Tools is a trademark of Entisoft.