I was sick of the old code I used to use to do this - when using large dimensions it could get quite slow so, I decided to investigate if it was possible using API and as it turns out it is, here is what I came up with:
VB Code:
Private Declare Sub RtlMoveMemory Lib "kernel32.dll" ( _ ByRef Destination As Any, _ ByRef Source As Any, _ ByVal Length As Long) Private Const VT_BYREF = &H4000& Private Function ArrayDims(varArray As Variant) As Integer Dim lngPointer As Long Dim intType As Integer RtlMoveMemory intType, varArray, 2 If (intType And vbArray) = 0 Then Exit Function End If RtlMoveMemory lngPointer, ByVal VarPtr(varArray) + 8, 4 If (intType And VT_BYREF) Then RtlMoveMemory lngPointer, ByVal lngPointer, 4 End If If lngPointer Then RtlMoveMemory ArrayDims, ByVal lngPointer, 2 End If End Function
Hope that helps someone,
Cheers,
RyanJ




Reply With Quote