API 2.0 Conversion Help

Hi, I’m just trying to carefully convert my codebase to API 2.0 and get Deprecated warnings for String.LeftB, String.MidB and String.RightB on the last line of code here. These should be replaced by MemoryBlocks. I only have no idea how? Can somebody please help me?

[code]Dim randomBytes As MemoryBlock = Crypto.GenerateRandomBytes(16)
randomBytes.LittleEndian = False
Dim p As Ptr = randomBytes

’ Adjust seventh byte
Dim value As Byte = p.Byte(6)
value = value And CType(&b00001111, Byte) ’ Turn off the first four bits
value = value Or CType(&b01000000, Byte) ’ Turn on the second bit
p.Byte(6) = value

’ Adjust ninth byte
value = p.Byte(8)
value = value And CType(&b00111111, Byte) ’ Turn off the first two bits
value = value Or CType(&b10000000, Byte) ’ Turn on the first bit
p.Byte( 8 ) = value

Dim result As String
result = EncodeHex(randomBytes)

’ LeftB, MidB, RightB are deprecated. Should replaced by MemoryBlock. How?
result = Join(Array(result.LeftB(8), “-”, result.MidB(9, 4), “-”, _
result.MidB(13, 4), “-”, result.MidB(17, 4), “-”, result.RightB(12)), “”)


The result string only contains a hexencoded string. With this string it doesn’t really matter if you use LeftB or Left.

Wow, that was easy. It works fine, thanks. To answer the initial question for cases like this, what would it look like with the memory blocks?