Help: Bit manipulation with VB 4.0 
Author Message
 Help: Bit manipulation with VB 4.0

Please help.  How do you perform bit manipulation in VB 4.0.  I'm used to C
where you can use the shift operator to mask for the specific bit you are
looking for.  I need to be able to mask off the high-order 6 bits to one
variable while retaining the lower order 2 bits for another variable.

Any help would really be appreciated.

Thanks,
Shawn.



Fri, 22 Jan 1999 03:00:00 GMT  
 Help: Bit manipulation with VB 4.0



Quote:
>Please help.  How do you perform bit manipulation in VB 4.0.  I'm used to C
>where you can use the shift operator to mask for the specific bit you are
>looking for.  I need to be able to mask off the high-order 6 bits to one
>variable while retaining the lower order 2 bits for another variable.

>Any help would really be appreciated.

>Thanks,
>Shawn.

Wouldn't
  H% = ( Var% AND &b11111100 ) \ 4
  L% = ( Var% AND &b00000011 )
work?

  ____    _    ____      ____  _____
 |  _ \  / \  / ___) __ | ___)(_   _) | Don Schullian
 | |_)  / _ \ \____\/  \|  _)   | |   |  Gramou 33
 |____//_/ \_\(____/\__/|_|     |_|   |  Papagou, 156-69
 ___________________________________  |  Greece
  =================================== |  ++30-1-654-6200

   -----------======### DOWNLOAD ###=========------------
            Nutz 'n Boltz for powerbasic v3.2  
              A library of everyday goodies
   DOWNLOAD N-B-V201.ZIP FROM YOUR FAVORITE SITE TODAY!



Fri, 22 Jan 1999 03:00:00 GMT  
 Help: Bit manipulation with VB 4.0

-> Please help.  How do you perform bit manipulation in VB 4.0.  I'm
-> used to C where you can use the shift operator to mask for the
-> specific bit you are looking for.  I need to be able to mask off the
-> high-order 6 bits to one variable while retaining the lower order 2
-> bits for another variable.

Well, how about something like:

LoBits = Byte AND 3 'lowest two bits
HiBits = Byte AND NOT 3 'third and higher bits

You can use AND to mask off whatever bits you want. If needed, you can
multiply or divide by powers of two to shift left or right. Look up the
Boolean operators, AND, OR, XOR (or EOR) and NOT.

                            dow



Fri, 22 Jan 1999 03:00:00 GMT  
 Help: Bit manipulation with VB 4.0

Quote:

> Please help.  How do you perform bit manipulation in VB 4.0.  I'm used to C
> where you can use the shift operator to mask for the specific bit you are
> looking for.  I need to be able to mask off the high-order 6 bits to one ...

The high order bits of *what*? An 8-bitter, a 16-bitter, a 32-bitter?

Quote:
> variable while retaining the lower order 2 bits for another variable.
> [ >8 ]

Dim thing As Long
Dim v1 As Long
Dim v2 As Long

        v0 = (thing & 0xFC000000)      ' yields most significant 6 bits of a Long
        v1 = (thing & 0xFC000000) / 0x04000000 ' moves top 6 bits into bottom
or perhaps
        v0 = (thing And 0xFC) / 0x04   ' yields 0 ... 63
        v1 = (thing And 0x03)          ' yields 0 ... 3
You pays yer money ...

--

Vox (0|+44)1642 216 200      |     |     |   Zetland Buildings, Exchange Square
Fax (0|+44)1642 216 201      o     o     *   Middlesbrough, Cleveland.  TS1 1DE
-- "I don't know much about quantum electrodynamics, but I know what I like" --



Sun, 24 Jan 1999 03:00:00 GMT  
 Help: Bit manipulation with VB 4.0

Quote:

>Please help.  How do you perform bit manipulation in VB 4.0.  I'm used to C
>where you can use the shift operator to mask for the specific bit you are
>looking for.  I need to be able to mask off the high-order 6 bits to one
>variable while retaining the lower order 2 bits for another variable.
>Any help would really be appreciated.
>Thanks,
>Shawn.

So whats wrong with

HWReg = HWReg And &H7F

RTFM Bitwise Operators...
  __   __   _______________________________
 //)) //)) | Richard RUDEK. MicroDek.      | Hey, Whadda ya
//\\ //\\  | Chatswood, Sydney. Australia. | want for nuting...
           `-------------------------------'



Sun, 24 Jan 1999 03:00:00 GMT  
 Help: Bit manipulation with VB 4.0


Quote:

>Please help.  How do you perform bit manipulation in VB 4.0.  I'm used to C
>where you can use the shift operator to mask for the specific bit you are
>looking for.  I need to be able to mask off the high-order 6 bits to one
>variable while retaining the lower order 2 bits for another variable.

>Any help would really be appreciated.

        Can't you AND, OR, NOT, etc. in Visual Basic?  You can do bit
manipulation in basic, it's just that the way it appears on the screen is
different.  The results are the same.

        if (aWord & aMask == aMask)...
        if (aWord and aMask) = aMask then....

                                        Damond



Sun, 24 Jan 1999 03:00:00 GMT  
 
 [ 6 post ] 

 Relevant Pages 

1. Help: Bit manipulation with VB 4.0

2. Bit Manipulation in Visual Basic 4.0

3. Bit Manipulation in Visual Basic 4.0

4. 16 bit API calls in VB 3 supported in 32 bit VB 4.0

5. VB 4.0 16-bit Bug with OLE (Was Re: VB 4.0 Enterprise and OLE)

6. VB 4.0 16 bit or 32 bit Escape Key

7. VB 4.0 (16-Bit)/Crystal Reports 3.0.1.32 (16-Bit) Print Preview Maximize Window

8. TIME TO WIN 32-Bit DLL for VB 4.0 32-Bit or Higher (VB5)

9. TIME TO WIN 32-Bit (v4.04) (+750 functions) for VB 4.0 32-Bit

10. VB 4.0 conversion from 32 bit to 16 bit

11. Calling a user-written 32-bit dll from 32-bit vb 4.0

12. VB 4.0: 16 bit vs 32 bit

 

 
Powered by phpBB® Forum Software