Still celebrating National IT Professionals Day with 3 months of free Premium Membership. Use Code ITDAY17

x
?
Solved

Bit shifting...

Posted on 1999-06-28
6
Medium Priority
?
822 Views
Last Modified: 2013-11-13
What's the best method of bit shifting in VB6?
I'm unable to find any methods to do the job so assume a bit of work is required. I need to be able to shift the bits by a set amount.
Thanks in advance.
0
Comment
Question by:lbowers
[X]
Welcome to Experts Exchange

Add your voice to the tech community where 5M+ people just like you are talking about what matters.

  • Help others & share knowledge
  • Earn cash & points
  • Learn & ask questions
6 Comments
 
LVL 6

Expert Comment

by:VBGuru
ID: 1520311
for bit wise operation use And Operator
Eqv,imp, Not,Or,Xor operators as below. Use the same to implement the shift
MyCheck = A And B
0
 
LVL 12

Expert Comment

by:mark2150
ID: 1520312
Don't forget integer divide \

AND won't *shift* bits. You've got to declare 'em integers and multiply by 2/4/8, etc. to implement shift lefts and you can do integer divide by 2/4/8 etc. for shift right.

M

0
 

Author Comment

by:lbowers
ID: 1520313
AND doesn't shift - It just selectively removes bits.
Thanks anyway.
0
VIDEO: THE CONCERTO CLOUD FOR HEALTHCARE

Modern healthcare requires a modern cloud. View this brief video to understand how the Concerto Cloud for Healthcare can help your organization.

 
LVL 6

Expert Comment

by:VBGuru
ID: 1520314
0
 
LVL 10

Accepted Solution

by:
viktornet earned 200 total points
ID: 1520315
here is an example...

public bit(1 to 8) as byte

'....form OnLoad

bit(1)=1:bit(2)=2:bit(3)=4:bit(4)=8:bit(5)=16:bit(6)=32:bit(7)=64:bit(8)=128

.......

function SHR(num as byte, bits as byte)
  SHR = num / bit(bits)
end function

function SHL(num as byte, bits as byte)
  SHL = num * bit(bits)
end function

that's about it, for a simply byte...

..-=ViKtOr=-..
0
 
LVL 10

Expert Comment

by:viktornet
ID: 1520316
opps ;-))

sorry, the line that reads..

bit(1)=1:bit(2)=2:bit(3)=4:bit(4)=8:bit(5)=16:bit(6)=32:bit(7)=64:bit(8)=128

should be replaced with the following :)

bit(1)=2:bit(2)=4:bit(3)=8:bit(4)=16:bit(5)=32:bit(6)=64:bit(7)=128:bit(8)=256

sorry for the inconvenience.. ;-)

..-=ViKtOr=-..
0

Featured Post

Free Tool: Site Down Detector

Helpful to verify reports of your own downtime, or to double check a downed website you are trying to access.

One of a set of tools we are providing to everyone as a way of saying thank you for being a part of the community.

Question has a verified solution.

If you are experiencing a similar issue, please ask a related question

If you have ever used Microsoft Word then you know that it has a good spell checker and it may have occurred to you that the ability to check spelling might be a nice piece of functionality to add to certain applications of yours. Well the code that…
This article describes how to use a set of graphical playing cards to create a Draw Poker game in Excel or VB6.
Get people started with the process of using Access VBA to control Excel using automation, Microsoft Access can control other applications. An example is the ability to programmatically talk to Excel. Using automation, an Access application can laun…
Get people started with the utilization of class modules. Class modules can be a powerful tool in Microsoft Access. They allow you to create self-contained objects that encapsulate functionality. They can easily hide the complexity of a process from…

715 members asked questions and received personalized solutions in the past 7 days.

Join the community of 500,000 technology professionals and ask your questions.

Join & Ask a Question