Bitwise Left Shift and Right Shift for VB

Category:
Dates and Math
Type:
Snippets
Difficulty:
Advanced
Author:
Nathan Moschkin

Version Compatibility: Visual Basic 6, Visual Basic 5

More information:
Provides Bitwise shifting for VB integer values. The first argument is the value, the second is the number of places to shift. For example, the C code:

int nNum=8;
nNum >> 2; // right shift two places, nNum now = 2

Can be written in VB like this using these functions:

dim nNum as Long
nNum = RShift(8, 2)

Instructions: Copy the declarations and code below and paste directly into your VB project.

Declarations:

Code: