Languages :: Visual Basic :: Copying Arrays |
|||
| By: Rj |
Date: 03/10/2003 00:00:00 |
Points: 300 | Status: Answered Quality : Excellent |
|
I have a byte array. How do I copy it to another array of same type. I need the program in visual basic 6.0 |
|||
| By: Rj | Date: 03/10/2003 21:58:00 | Type : Comment |
|
| Quite urgent. |
|||
| By: VGR | Date: 03/10/2003 22:19:00 | Type : Assist |
|
| you do a for(i) loop and copy firstarray to newarray... |
|||
| By: Rj | Date: 03/10/2003 22:26:00 | Type : Comment |
|
| Ummm..,....I am sorry for not mentioning before. Its too slow when I try that. I need a quick way. This byte array is quite big. |
|||
| By: Arthur_Wood | Date: 03/10/2003 22:40:00 | Type : Answer |
|
| there is no other way. You MUST copy each entry form one array to the other. If you try to simply set NewArray = OldArray, New Array will hold a REFERENCE to the OldArray. AW |
|||
| By: stoliD | Date: 03/10/2003 23:15:00 | Type : Assist |
|
| thats right. All you could do is set two different variables to the same pointer to your byte-array. Else you would need to copy every single element. Perhaps you could explain what u need this copy for, and if you need a complete copy.... maybe you could share the code... and well find another solution. |
|||
| By: Rj | Date: 04/10/2003 00:12:00 | Type : Comment |
|
| Private Declare Sub CopyMemory Lib "KERNEL32" Alias "RtlMoveMemory" ( hpvDest As Any, hpvSource As Any, ByVal cbCopy As Long) This was one suggestion given in another forum. Itried using this but it gives a memory error. |
|||
| By: johnQuestion | Date: 05/10/2003 01:42:00 | Type : Comment |
|
| You might want to try this, if your array is 20 elements long, then run a loop to transfer the data: Dim Array1(1 to 20) As Single 'array with data Dim Array2(1 to 20) As Single 'array w/o data Dim i As integer For i = 1 to 20 Array2(i) =Array1(i) Next i |
|||
| By: GHehmann | Date: 09/10/2003 04:09:00 | Type : Comment |
|
the declaration from the sub is wrong Public Declare Sub CopyMemory Lib "kernel32" Alias "RtlMoveMemory" (Destination As Any, Source As Any, ByVal Length As Long) |
|||
| By: johnQuestion | Date: 09/10/2003 06:43:00 | Type : Comment |
|
| single would be used for numbers, string for letters and words, what are you using? There are also double, integer that are commonly used |
|||
|
Do register to be able to answer |
|||
©2010 These pages are served without commercial sponsorship. (No popup ads, etc...). Bandwidth abuse increases hosting cost forcing sponsorship or shutdown. This server aggressively defends against automated copying for any reason including offline viewing, duplication, etc... Please respect this requirement and DO NOT RIP THIS SITE.
Please DO link to this page!








