News:

MyKidsDiary.in :: Capture your kids magical moment and create your Online Private Diary for your kids

Main Menu

This example shows how to use the RtlMoveMemory (CopyMemory) API function

Started by nandagopal, Dec 03, 2008, 07:36 PM

Previous topic - Next topic

nandagopal

The CopyArray subroutine copies part of a 2-dimensional array into part of another 2-dimensional array. It calculates the number of bytes in each row of data to be copied. It then loops through the rows of data to be copied and uses CopyMemory to copy the data.


' 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