Title | Use the RtlMoveMemory (CopyMemory) API function to copy memory between 2-D arrays in VB .NET |
Description | This example shows how to use the RtlMoveMemory (CopyMemory) API function to copy memory between 2-D arrays in VB .NET. |
Keywords | RtlMoveMemory, copy memory, MemCopy, CopyMemory, array, memory |
Categories | Tips and Tricks, Miscellany, Software Engineering, VB.NET |
|
' Copy fr_array entries (fr_r1, fr_c1) to (fr_r2, fr_c2)
' into to_array starting at position (to_r, to_c).
Private Sub CopyArray(ByVal fr_array(,) As Long, ByVal _
to_array(,) As Long, ByVal fr_r1 As Integer, ByVal _
fr_r2 As Integer, ByVal fr_c1 As Integer, ByVal fr_c2 _
As Integer, ByVal to_r As Integer, ByVal to_c As _
Integer)
' Copy by rows.
Dim bytes_per_row As Long = (fr_c2 - fr_c1 + 1) * _
Len(bytes_per_row)
For r As Integer = fr_r1 To fr_r2
CopyMemory(to_array(to_r, to_c), fr_array(r, _
fr_c1), bytes_per_row)
to_r += 1
Next r
End Sub
|