473,432 Members | 2,016 Online
Bytes | Software Development & Data Engineering Community
Post Job

Home Posts Topics Members FAQ

Join Bytes to post your question to a community of 473,432 software developers and data experts.

Arrays and CopyMemory

Hi!

Just one question

Is it legal to copy the array descriptor in this way :

Dim lngArr1() as Long
Dim lngArr2() as Long
Redim lngArr1(2) as Long

CopyMemory ByVal VarPtrArray(lngArr2), ByVal VarPtrArray(lngArr1), 4

Or can you do a shallow-copy of an array in some other way?

/Mikael Lundberg
Jul 17 '05 #1
1 5701
On 20 Feb 2004 06:55:04 -0800, Mikael Lundberg <mi*************@home.se>
wrote:
Hi!

Just one question

Is it legal to copy the array descriptor in this way :

Dim lngArr1() as Long
Dim lngArr2() as Long
Redim lngArr1(2) as Long

CopyMemory ByVal VarPtrArray(lngArr2), ByVal VarPtrArray(lngArr1), 4

Or can you do a shallow-copy of an array in some other way?

/Mikael Lundberg


Your code looks like it is supposed to copy the pointer of one array to
another.
This fools VB into having both array variables point to the same memory
location. This is not leagal, but it works on all versions of Windows.
However, the code will crash if you don't use CopyMemory to clear lngArr2
before it goes out of scope.

I'm not sure what you mean by "shallow-Copy".

There is virtually never a reason to do this: The net effect of copying
the pointer of lngArr1 to lngArr2, then changing values in lngArr2, is
changing values in lngArr1. The only reason to do this would be if you
didn't have access to lngArr1, like when lngArr1 is in a Class and you
want to change it from outside the Class.
Jul 17 '05 #2

This thread has been closed and replies have been disabled. Please start a new discussion.

Similar topics

5
by: Adam Parkin | last post by:
Hello all, I am seeking some help with the following problem. I'm working on an application where I have a resource file, and in this resource file what I want to store is a list of file names...
5
by: RaviAmbani | last post by:
I am facing a problem in copymemory api in vb.net . the problem is that i have used copymemory api extensively in my project originally written in vb6.0 , now when i'm migrating my project to...
5
by: active | last post by:
Has anyone used CopyMemory with DotNet? In this instance I define it as: Private Declare Sub CopyMemory Lib "KERNEL32" Alias "RtlMoveMemory" (ByRef hpvDest As DEVMODE, ByRef hpvSource As Byte,...
9
by: Paul W | last post by:
Hello Group, I'm a .net newbie with a couple of questions. First, Debug.WriteLine() doesn't send any output to the immediate window, anybody know why that might be? Second, what is the .net...
4
by: Turtle | last post by:
I've been using SendKeys to automate a small utility which doesn't expose an automation interface, but ran into a problem, for which I found the suggestion that I use the WinAPI SendInput call...
10
by: Dennis | last post by:
I am trying to use CopyMemory to copy arrays as follows: Private Declare Sub CopyMemory Lib "kernel32" Alias "RtlMoveMemory" (ByVal pDst As Long, ByVal pSrc As Long, ByVal ByteLen As Integer) ...
5
by: _iycrd | last post by:
After numerous problems, I'm having second thoughts about using C++/CLI to wrap a native DLL. On the other hand, PInvoke seems like it will take a huge amount of work, if it will work at all. ...
0
by: android | last post by:
Hi all. I should migrate old vb6 code in vb.net but I been clashed with the copymemory api! Here below is a vb6 method that manages the current sample of a waveform file in a buffer for retrieving...
0
by: akumar | last post by:
Hello Please send me the syntax of CopyMemory function in VB.net thnax akumar
1
by: nemocccc | last post by:
hello, everyone, I want to develop a software for my android phone for daily needs, any suggestions?
1
by: Sonnysonu | last post by:
This is the data of csv file 1 2 3 1 2 3 1 2 3 1 2 3 2 3 2 3 3 the lengths should be different i have to store the data by column-wise with in the specific length. suppose the i have to...
0
marktang
by: marktang | last post by:
ONU (Optical Network Unit) is one of the key components for providing high-speed Internet services. Its primary function is to act as an endpoint device located at the user's premises. However,...
0
by: Hystou | last post by:
Most computers default to English, but sometimes we require a different language, especially when relocating. Forgot to request a specific language before your computer shipped? No problem! You can...
0
Oralloy
by: Oralloy | last post by:
Hello folks, I am unable to find appropriate documentation on the type promotion of bit-fields when using the generalised comparison operator "<=>". The problem is that using the GNU compilers,...
0
jinu1996
by: jinu1996 | last post by:
In today's digital age, having a compelling online presence is paramount for businesses aiming to thrive in a competitive landscape. At the heart of this digital strategy lies an intricately woven...
0
tracyyun
by: tracyyun | last post by:
Dear forum friends, With the development of smart home technology, a variety of wireless communication protocols have appeared on the market, such as Zigbee, Z-Wave, Wi-Fi, Bluetooth, etc. Each...
0
agi2029
by: agi2029 | last post by:
Let's talk about the concept of autonomous AI software engineers and no-code agents. These AIs are designed to manage the entire lifecycle of a software development project—planning, coding, testing,...
0
by: conductexam | last post by:
I have .net C# application in which I am extracting data from word file and save it in database particularly. To store word all data as it is I am converting the whole word file firstly in HTML and...

By using Bytes.com and it's services, you agree to our Privacy Policy and Terms of Use.

To disable or enable advertisements and analytics tracking please visit the manage ads & tracking page.