Re: Arrays



Thanks Ralph. I guess, I will use loops. By the way, in VB is there any
way of using pointers for arrays, like C or Fortran. If so, then I can pass
the pointer.

Bob

"Ralph" <nt_consulting64@xxxxxxxxx> wrote in message
news:OkqjLlxBJHA.4932@xxxxxxxxxxxxxxxxxxxxxxx

"Bob" <someonw@xxxxxx> wrote in message
news:uL$94mwBJHA.2292@xxxxxxxxxxxxxxxxxxxxxxx
Hi everyone:

1- I have two arrays Arr1 and Arr2 of sizes 100 and 25 respectively. I
want
to send the last 25 elements of Arr1 into Arr2, for example elements 76
to
100. Is there any way of doing this without loops, like for example;
Arr2=Arr1(76)

2- What is I want to pass the last 25 elements of Arr1 to another routine
sub first(Arr2)
.
.
end sub

call first(Arr1(76))
is this possible?

Thanks for all your help.

Bob


Depends what the array is an array of.

If you have Byte Arrays then you could simply do this...
Dim Arr2() As Byte
Arr2 = MidB(Arr1, 76, 100)

[The Array must start with meaningful data at '1', because that is where
Mid
starts.]

You could use the CopyMemory API in some cases, but note it is only a
shallow copy. It would produce only a 'clone' if for example if you had an
Array of Objects.

In general while a loop may look like extra processing, with compiler
optimization it is likely not that noticably slower for arrays with sizes
within reason - and in fact is doing nothing more than what the CopyMemory
routine would be doing. While providing an opportunity to perform deep
copies for complex objects.

Warning Air Code!
Dim Arr2() As MyCreature
ReDim Arr2(25)
For k = 0 To 24
Arr2(k) = Arr1(k + 75)
Next




.



Relevant Pages

  • Re: Global array operations: a performance hit?
    ... as if many DO loops were executed instead than just one. ... global array operations then? ... Note that the usual terminology is something more like "whole array ... once in a while they might also get you faster execution, ...
    (comp.lang.fortran)
  • Re: Puppy Mastiff wants to Nip at Faces
    ... first couple of weeks of an introductory data structures ... it seems to me by my recollection that loops were... ... in my first college textbook on structured programming. ... they did was loop through an array to show how you could easily access ...
    (rec.pets.dogs.behavior)
  • Re: Inefficient code?
    ... line is written to the output file. ... or read it into an array. ... # Backup File Field Positions ... Define 'my %found;' above the loops. ...
    (perl.beginners)
  • Re: Global array operations: a performance hit?
    ... when using array operations you have additional information ... which is not always the case in DO loops. ... optimizing array expressions. ... The compiler has to ...
    (comp.lang.fortran)
  • Re: Segmentation Fault...
    ... > int i, loops; ... your program will walk past the end of the 'args' array ... The array does not contain valid pointers. ...
    (comp.lang.c)

Loading