473,395 Members | 1,639 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,395 software developers and data experts.

How to make a dynamic array with ReDim and Preserve?

I was wondering how I can make an array that takes in integers, but have an endless array space so I don't have to limit my array in a for loop that ends in a large number
May 19 '15 #1
1 1259
Seth Schrock
2,965 Expert 2GB
I would keep a global variable that stores the max subscript for your array. Each time that you need to add another element to the array, just increment that variable and then ReDim your array using the Preserve option.
Expand|Select|Wrap|Line Numbers
  1. intMAX_SUBSCRIPT += 1
  2. ReDim Preserve intMyArray(intMAX_SUBSCRIPT)
  3.  
  4. intMyArray(intMAX_SUBSCRIPT) = 15  'my new number
May 20 '15 #2

Sign in to post your reply or Sign up for a free account.

Similar topics

2
by: | last post by:
Is it correct to think that after reducing the populated array's size from say, 10 to 5 with redim preserve myArray(i) an attempt to access an element above the fifth does not cause a...
1
by: GeckoNewsgroup | last post by:
Hi, When a try this script: NbrAuteur = 19 Dim arrTestArray() intSize = 0 1: For x = 0 to (nbrAuteur - 1)
6
by: LP | last post by:
Hello, What is C# equivalent of rediming an array and preserving exciting elements. VB.NET syntax looks something like this: ReDim Preserve myArray(5) Thank you
6
by: John Grandy | last post by:
Does C# have an equivalent for VB.NET's Redim Preserve ? ReDim Preserve increases the final dimension of any array while preserving the array's contents (however, the type of the array may not be...
1
by: Vijay Balki | last post by:
I have a array who's size I will know only at runtime. How do I initialize the size of the array at runtime? Is there a equivalent of ReDim in .NET?? VJ
5
by: Paul | last post by:
Off the cuff, does anyone know if arraylist is more efficeint at adding items to an array than redim preserve? Paul <begin loop> Dim c As Integer = SomeArray.GetUpperBound(0) + 1 ReDim...
19
by: Tom Jastrzebski | last post by:
Hello, I was just testing VB.Net on Framework.Net 2.0 performance when I run into the this problem. This trivial code attached below executed hundreds, if not thousand times faster in VB 6.0...
2
by: hien_tran | last post by:
As in VB6, is it possible to create a dynamic array in VB NET and then use Redim Preserve after knowing the index of the array? Thank you in advance for your help.
2
by: htran | last post by:
Hello, is is possible to create a dynamic array in VB NET as in VB6 and then use Redim Preserve after determining the index of the array? Thank you in advance for your help.
3
by: Brian Piotrowski | last post by:
Hi All, I've probably done this before, but for the life of me I can't remember how I did it. I need to move values from a DB table into an array to be used for other queries. The number of...
0
by: ryjfgjl | last post by:
If we have dozens or hundreds of excel to import into the database, if we use the excel import function provided by database editors such as navicat, it will be extremely tedious and time-consuming...
0
by: emmanuelkatto | last post by:
Hi All, I am Emmanuel katto from Uganda. I want to ask what challenges you've faced while migrating a website to cloud. Please let me know. Thanks! Emmanuel
0
BarryA
by: BarryA | last post by:
What are the essential steps and strategies outlined in the Data Structures and Algorithms (DSA) roadmap for aspiring data scientists? How can individuals effectively utilize this roadmap to progress...
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
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
by: Hystou | last post by:
Overview: Windows 11 and 10 have less user interface control over operating system update behaviour than previous versions of Windows. In Windows 11 and 10, there is no way to turn off the Windows...
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...

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.