-
Dec 20th, 2008, 07:41 PM
#1
Thread Starter
Addicted Member
[RESOLVED] Changing size of array
I am using an array in loop and I need to change it's size to make the program use less memory resources.
Redim only works 1 time as I tried it.
-
Dec 20th, 2008, 07:45 PM
#2
Re: Changing size of array
You cannot resize a static array. Static arrays are declared like the following:
Code:
Dim ABC(100) As Long ' static array
Dim XYZ() As Long ' dynamic array
ReDim resizes dynamic arrays without trying to save the existing array data.
ReDim Preserve resizes and saves existing data.
I think we may need to see your loop.
-
Dec 20th, 2008, 07:47 PM
#3
Re: Changing size of array
vb Code:
Dim myArray() 'Dont specify any element number. It will be a dynamic array. Redim myArray(1 To 100) 'gives a dimension of 100 elements. it will clean up the array also. ReDim Preserve myArray(1 To 99) 'will reduce the array to 99 elements. the 'Preserve' property will preserves the elements in the array.
Is this you are looking for?
LaVolpe is the winner (i was too late)
Last edited by Jim Davis; Dec 21st, 2008 at 04:37 AM.
-
Dec 21st, 2008, 01:35 AM
#4
Re: Changing size of array
[Pedantic]
gives a Dimension of 101 elements (0 to 100) unless you've specified Option Base 1 in the General Section of the Form
[/Pedantic]
-
Dec 21st, 2008, 04:37 AM
#5
Re: Changing size of array
@Doogle is right, i was forgot to mention. (remarks fixed as well).
-
Dec 21st, 2008, 06:28 AM
#6
Thread Starter
Addicted Member
Re: Changing size of array
Yeah I was using Dim MyArray(32) as string.
Thanks all!
resolved
Posting Permissions
- You may not post new threads
- You may not post replies
- You may not post attachments
- You may not edit your posts
-
Forum Rules
|
Click Here to Expand Forum to Full Width
|