CodeGuru Home VC++ / MFC / C++ .NET / C# Visual Basic VB Forums Developer.com
Results 1 to 3 of 3
  1. #1
    Join Date
    Sep 1999
    Location
    TVM, Kerala, India
    Posts
    210

    How we can implement right shifting a word in VB ?... pl help

    Dear All,
    How we can implement a right shifting of a word in VB?/// please heplp me

    Thanks in advance
    Kareem.



  2. #2
    Join Date
    Sep 1999
    Location
    Trivandrum, Kerala, INDIA.
    Posts
    32

    Re: How we can implement right shifting a word in VB ?... pl help



    dim w as long
    'Don't instanciate to "Integer" due to overflow problems

    w=&h89ab
    'This is now a word(2bytes long)

    w=w/2
    'Division by 2 is right shift by 1 bit
    'Division by 2 raised to 8 is rightshift by 1 byte

    'Multiplication by 2 is leftshift by 1 bit, and so on





    OK now, I hope.

    Deepak



  3. #3
    Join Date
    May 1999
    Posts
    3,332

    Re: How we can implement right shifting a word in VB ?... pl help

    this code was published a while ago by (if I remember correctly) "Crazy D @ work"


    private Function RShiftWord(byval w as Integer, byval c as Integer) as Integer
    Dim dw as Long
    If c = 0 then
    RShiftWord = w
    else
    dw = w And &HFFFF&
    dw = dw \ (2 ^ c)
    RShiftWord = dw And &HFFFF&
    End If
    End Function





Posting Permissions

  • You may not post new threads
  • You may not post replies
  • You may not post attachments
  • You may not edit your posts
  •  





Click Here to Expand Forum to Full Width

Featured