How can I extract the bits from a Single variable in vba?
For example, I want to extract bits 23 to 30 and place them into the lowest 8 bits of an integer.
Sign Up to our social questions and Answers Engine to ask questions, answer people’s questions, and connect with other people.
Login to our social questions & Answers Engine to ask questions answer people’s questions & connect with other people.
Lost your password? Please enter your email address. You will receive a link and will create a new password via email.
Please briefly explain why you feel this question should be reported.
Please briefly explain why you feel this answer should be reported.
Please briefly explain why you feel this user should be reported.
For transferring the bit settings of the
shortvariable to anint, the fastest solution is a ‘quick and dirty’ CopyMemory approach, as seen here.For reading and writing single bits in integers, see here. The relevant source code is this: