Re: array dimensioning

Tech Tip: Click here to run a free scan for Windows Errors and optimize PC performance



Rod;

I'm unable to locate my thread either, using relevant keywords!!
I've tried even via the Microsoft Community Notification - Re:: "Array
Declaration Problem ??" 28/6/2008 with no avail.
If I recall correctly, it had something to do with complex numbers and
ReDim. My latest post was a summary solution with the code of Function
Zroots* and likely (but not sure!) a numerical example posted ~ end of June
2008
Will try again later today.

According to my notes, I did post *a* solution in the *other* Excel forum at:
http://www.mrexcel.com/forum/showthread.php?t=326067&page=2

HTH.


"RocketRod" wrote:

I can't find your post referred to - can you send it again with the answer -
I think I have a problem with using Redim but if its already got a solution
...
Thanks

Rod

"monir" wrote:

Hello;

I've just reviewed with much interest the replies here and found them to be
very useful and related to my recent question.

Could someone please review the thread: "Array Declaration Problem" and my
latest summary post (yesterday, June 22,'08), and identify where the array
declaration went wrong ??

Thank you kindly, will very much appreciate your help.


"Chip Pearson" wrote:

Just FYI...

VB/VBA doesn't use the same type arrays as does native C/C++. Instead, it
uses SAFEARRAYs (available in C/C++ with MFC or various APIs).


--
Cordially,
Chip Pearson
Microsoft Most Valuable Professional
Excel Product Group
Pearson Software Consulting, LLC
www.cpearson.com
(email on web site)




"LesHurley" <LesHurley@xxxxxxxxxxxxxxxxxxxxxxxxx> wrote in message
news:4C03B05A-C110-4B4E-8B69-2D47485B9269@xxxxxxxxxxxxxxxx
ilia; sory for the long delay in answering your question. In C/C++ you
create dynamic arrays and change their dimensions using the malloc()
function
to create and expand and the free() function to release previously
allocated
memory. Such a capability is essential in database programs where arrays
of
large user defined class objects are the normal. Ordinarily no one knows
in
advance how many iems the array will hold or how much memory will be
required, thus the need for dynamic allocation. It's been 5 or 6 years
since
I did any C++ programming and I had to go back and look it up. HTH.
--
Thanks for your help


"ilia" wrote:

Just curiosity - how in C++ do you increase/decrease the dimension of
an array? C++ doesn't even know what an array is, from what I
understand.


On Mar 15, 12:23 pm, LesHurley <LesHur...@xxxxxxxxxxxxxxxxxxxxxxxxx>
wrote:
Thanks everyone
--

"Alan Beban" wrote:
Rick Rothstein (MVP - VB) wrote:
Then you missed the part where Chip wrote about the Preserve
keyword.

You can ReDim the array as often as you want. ReDim will cause
the
existing
contents of the array to be lost unless you use the Preserve
modifier.

ReDim Preserve Arr(0 To 11)

Rick

A bit more needs to be said.

If Arr is a true variant() type array [e.g.,
Dim Arr()
ReDim Arr(1 to 10, 1 to 2)]
then with the Preserve keyword you can change only the upper bound of
the last dimension
[e.g.,
Dim Arr()
Redim Arr(1 to 10, 1 to 2)
ReDim Preserve Arr(1 to 10, 1 to 4)]
In this case, if you try to change either bound of the 1st dimension,
or
the lower bound of the 2nd dimension, you will get a Subscript out of
range error.

If, however, Arr is a an array contained within a Variant type
variable
[e.g.,
Dim Arr
Redim Arr(1 to 10, 1 to 2)]
then with the Preserve keyword you can change either or both bounds
of
the last dimension [e.g.,
Dim Arr
Redim Arr(1 to 10, 1 to 2)
ReDim Preserve Arr(1 to 10, 0 to 3)]

If the functions in the freely downloadable file at
http:/home.pacbell.net/beban are available to your workbook, then you
can use the ResizeArray function to preserve the values of the array
that is passed to it and change the lower and/or upper bounds of any
or
all of the dimensions of a one-, two- three- or four-dimensional
array, or increase (up to 4) or decrease the number of the array's
dimensions (whether or not the array is contained within a Variant
type
variable).

Alan Beban



.



Relevant Pages

  • Re: Newbie question about "NEW: Keyword
    ... etc), use the NEW keyword. ... And the method GetFullNameshould be a prototype method, ... The array data structure, encapsulated by the Array ...
    (comp.lang.javascript)
  • Re: perl grep problem
    ... > basically the script reads all the data from files in a directory into ... > an array. ... > works fine) and $ARGVis the user input word to search for. ... > inputs the keyword to search for and we loop step 2 as many times as ...
    (comp.lang.perl.misc)
  • Re: C/C++ typedef in C#
    ... in some situation typedef in C# can be done using "using" keyword ... it makes an alias for any type name ONLY locally to file where is has ... When porting please remember that .NET Framework is single class ... array of value objects is fully initialized after creaton of array it ...
    (rec.games.roguelike.development)
  • Re: KEYWORDS AND WHILE
    ... |>>> redundant parentheses and the fact that procedures are "nouns" rather ... |> analysis of languages where language keywords were not reserved. ... You can't tell whether WHILE is a keyword ... or a variable (assuming that you have an array called WHILE). ...
    (comp.lang.pl1)
  • Re: Error on UBound with Dynamic Array
    ... ReDim Preserve arrSplit+ 1) ... is that arrSplit has not yet been dimmed as having any dimension. ... need to use a dynamic array and may be checking the boundries, ... Public Function Split(csvString As String) As Variant ...
    (microsoft.public.access.modulesdaovba)