Hi All:

Searching Deja didn't turn up anything, so I thought I'd try here.

I'm being passed a Variant which contains an array of bytes. I need to
break it into 3 pieces, looping is slow, and CopyMemory seems ideal. I
can't seem to get a pointer to the data in the variant.

The following code illustrates my problem...

Option Explicit
Private Declare Sub CopyMemory Lib "kernel32" Alias "RtlMoveMemory"
(Destination As Any, Source As Any, ByVal Length As Long)

Sub Test()
Dim bytSource(0 To 3) As Byte
Dim bytDest(0 To 3) As Byte
Dim varTest As Variant

'load up some test data
bytSource(0) = 0
bytSource(1) = 1
bytSource(2) = 2
bytSource(3) = 3

'this creates a variant of subtype byte array (8209 according to vartype)
varTest = bytSource

'this works just fine, you can look at the bytes in the locals window
CopyMemory bytDest(0), bytSource(0), 4

'none of the following work
CopyMemory bytDest(0), varTest(0), 4
CopyMemory bytDest(0), VarPtr(varTest(0)), 4
CopyMemory bytDest(0), ByVal (VarPtr(varTest(0))), 4

End Sub

Any help would be appreciated.