Home
Search
 
What's New
Index
Books
Links
Q & A
Newsletter
Banners
 
Feedback
Tip Jar
 
C# Helper...
 
XML RSS Feed
Follow VBHelper on Twitter
 
 
 
MSDN Visual Basic Community
 
 
 
 
 
TitleUse the RtlMoveMemory (CopyMemory) API function to copy memory between 2-D arrays in VB .NET
DescriptionThis example shows how to use the RtlMoveMemory (CopyMemory) API function to copy memory between 2-D arrays in VB .NET.
KeywordsRtlMoveMemory, copy memory, MemCopy, CopyMemory, array, memory
CategoriesTips and Tricks, Miscellany, Software Engineering, VB.NET
 
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
 
 
Copyright © 1997-2010 Rocky Mountain Computer Consulting, Inc.   All rights reserved.
  Updated