Link to home
Start Free TrialLog in
Avatar of dkilby
dkilbyFlag for Canada

asked on

VS 2002 + bitshift the number by 8 bits

I am trying a FTP class from Microsoft website, and am using VS 2002, there is one section as seen below.  It doesn't work.

I have tried this code on a different machine with VS 2003 and it works fine, so it looks like the code to muliple the number by 2 ot the power of 8 is working.

        ' Make this call in Visual Basic .NET 2002. You want to
        ' bitshift the number by 8 bits. In Visual Basic .NET 2002 you must
        ' multiply the number by 2 to the power of 8.
        Dim port As Int32 = port = parts(4) * (2 ^ 8)

        ' Make this call and then comment out the previous line for Visual Basic .NET 2003.
        'Dim port As Int32 = port = parts(4) << 8

Can i do this some other way.
Avatar of S-Twilley
S-Twilley

I might be missing something but couldn't you use this instead

Dim port As Int32 = parts(4) * (2 ^ 8)

That should be a valid line assuming the value in "parts(4)" is a number.

Avatar of Bob Learned
What other way are you looking for?

Bob
Avatar of dkilby

ASKER

I tried using Dim port As Int32 = parts(4) * (2 ^ 8) in VS 2002 and it comes back with a value of 0, it doesn't seem to work, because it doesnt return a valid port to connect to.
Avatar of dkilby

ASKER

just stepped through and this is the value

parts(4) = 249

port = 249 * (2 ^ 8)

after the calculation port = 0
If it's returning 0 (i.e. assigning 0 to port)... then your problem is in the parts(4) as far as i know... because that is a legit assignment.

So if this code works in VS 2003 and not in 2002.. there is something not working with the assignment to the parts array in the different versions of VS (that sounds confusing)
ok... will double check with mine
ASKER CERTIFIED SOLUTION
Avatar of S-Twilley
S-Twilley

Link to home
membership
This solution is only available to members.
To access this solution, you must be a member of Experts Exchange.
Start Free Trial
Avatar of dkilby

ASKER

very strange, when i use the code above it works, but if i use the one line it doesnt

oh well however it works is all i need.

Thanks
No problem...  maybe the second pair of eyes helped :P