Splitting multibyte variables

I have a variable CRCAsUShort16 bits unsigned andCRChi/CRCloAsByte.
In Delphi and most assemblers I can split CRC into 2 bytes by (or similar)

CRChi=High(CRC) 'Get the top 8 bits
CRClo=Low(CRC) ''Get the bottom 8 bits

How do I do this in VB2005?

As you may gather I want to get the CRC value for strings or characters send out and then append the CRC (it may be High/Low or Low/High). If there is a way of dividing even larger integers such as 3 or 4 bytes (for 24 and 32 bits CRC) then it would even be better. I have seen something about converting integers into byte arrays but I'm not clear on how to go about it.

Thanks, you lot have been very helpful so farSmileSmile

[1130 byte] By [samperiau] at [2007-12-17]
# 1

Dim crc As UShort = &HAABB

Dim Lbyte As Byte = crc And &HFF

crc = crc >> 8

Dim Ubyte As Byte = crc

It works !

ReneeC at 2007-10-6 > top of Msdn Tech,Visual Studio Express Editions,Visual Basic 2005 Express Edition...
# 2
Bonza mate, it's a bottler Big Smile (translation: works well, worth keeping, thank you)
samperiau at 2007-10-6 > top of Msdn Tech,Visual Studio Express Editions,Visual Basic 2005 Express Edition...
# 3

Thanks again for your help. I have finally had the time to put it to good use (went to bed 1am last nightTongue TiedTongue Tied) and got it all working. I had to reverse the order of things...it will have to do with big/little indians and cowboys I think Big Smile but this is the final result.

CRClo = CRC And &HFF 'Get lsb of CRC
CRC = CRC >> 8
CRChi = CRC
'Get MSB of CRC
SerialPort1.Write(Chr(CRChi))
SerialPort1.Write(Chr(CRClo))

I'm almost up to the point of finally putting my application on my website for the whole world to see. Just waiting for my VS2005 to arrive so it's all legal and I don't get struck by a lighting bolt for using the express edition for commercial purposes Smile

JohnSamperi at 2007-10-6 > top of Msdn Tech,Visual Studio Express Editions,Visual Basic 2005 Express Edition...