0

I have some data that I am scraping from a local device on my LAN. It uses javascript to format the data, but I need to perform the same formatting in VB.net. Here is an abbreviated version of the javascript:

var n = 0x740900;

alert(((n >>> 8) & 0xFF) + 1);
//result is 10

n = 0x740a00;

alert(((n >>> 8) & 0xFF) + 1);
//result is 11

Essentially, I need to feed a variable (n in this case) into the calculation, and then I am returned a value.

From my research, the >>> is a zero-fill right shift operator. I've been trying to replicate it in VB.net, but the >>> operator isn't available.

Any ideas how I can replicate this in VB.net?

4
  • Is it just >> ? msdn.microsoft.com/en-us/library/dezyht83.aspx Commented Nov 24, 2016 at 3:07
  • May I know what type of number is in the var Commented Nov 24, 2016 at 3:25
  • It's a hex number that has the month and the year in it. The operation I am attempting extracts the month (10 is for October, 11 is for November, etc) Commented Nov 24, 2016 at 3:27
  • 1
    its too late hehe already have the code but the other get it first. Commented Nov 24, 2016 at 3:29

1 Answer 1

3
Dim n As UInteger = &H740900
Console.WriteLine(((n >> 8) And &HFF) + 1)
'result is 10
n = &H740A00
Console.WriteLine(((n >> 8) And &HFF) + 1)
Console.ReadKey()
'result is 11
Sign up to request clarification or add additional context in comments.

1 Comment

Awesome! That did the trick. The "And" was throwing me off as well. Thanks so much!

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service and acknowledge you have read our privacy policy.

Start asking to get answers

Find the answer to your question by asking.

Ask question

Explore related questions

See similar questions with these tags.