What Is Dynamic Array In VB And How It Is Used?
I want to know the syntax to use dynamic array in VB ?
1 Answer - Sort by: Date | Rating
Array whose size can be changed at runtime is called dynamic array.
The dynamic array is also sometimes called as redimmable array.
This type of array is used to store a list of values which can shrink or extend during execution of program.
Thus dynamic arrays are more flexible than the static/fixed size arrays.
Unlike the fixed size array, the size of the dynamic array is not specified at the time of declaration as:
Dim dynamicArray() as integer
Where 'dynamicArray' is name of a dynamic array of integer type.
The size of dynamic array is set by using a keyword 'Redim'.
The memory is allocated for array when the Redim is encountered (because the above declaration does not allocate memory space for the dynamic array).
The Redim is used as:
Redim dynamicArray(5)
This statement allocates the memory for 6 array elements (if lower bound is 0). Otherwise we can specify both the upper bound and lower bound of array by using Redim as:
Redim dynamicArray(1 to 5)
The size of dynamic array can be changed many times by using Redim, but each time Redim is encountered the previous values in that array are lost.
But there is also a way to preserve these previous values.
We can also change the upper and lower bounds of array by Redim.
The dynamic array is also sometimes called as redimmable array.
This type of array is used to store a list of values which can shrink or extend during execution of program.
Thus dynamic arrays are more flexible than the static/fixed size arrays.
Unlike the fixed size array, the size of the dynamic array is not specified at the time of declaration as:
Dim dynamicArray() as integer
Where 'dynamicArray' is name of a dynamic array of integer type.
The size of dynamic array is set by using a keyword 'Redim'.
The memory is allocated for array when the Redim is encountered (because the above declaration does not allocate memory space for the dynamic array).
The Redim is used as:
Redim dynamicArray(5)
This statement allocates the memory for 6 array elements (if lower bound is 0). Otherwise we can specify both the upper bound and lower bound of array by using Redim as:
Redim dynamicArray(1 to 5)
The size of dynamic array can be changed many times by using Redim, but each time Redim is encountered the previous values in that array are lost.
But there is also a way to preserve these previous values.
We can also change the upper and lower bounds of array by Redim.
0
1
- Write A Java Program To Store A Number Find If It Is Positive Or A Negative Number If Positive Print I Am The First?
- Write A Java Program To Store 3 Numbers Find Sum And Product And Print It?
- Finds The Factorial Of The Numbers That Lie Between 1 And 10 Using Nested For Loop?
- What Is Polymorphism ? With Example
- How To Pull A Command Prompt?
- Where Can I Find Pdf Files Of The Old White Wolf Rpg Books?
- How To Create A Header File In C Language?
- What Is Difference Between HTML Vs XHTML?
- How The Efficiency And Integrity Of The Data Is Maintained At All?
- A Form In Visual Basic Is Best Described As What?
- How To Update The Sim 3 Expansion?
- Program To Calculate Change The Name To Write In Any Word In English And It Will Convert To Change Any Language Of User?
- What Are The Risks In Undertaking A Systems Analysis And Design Activity?
- Do While Loop In C++ Output?
- What Is File-based Approach?
- What Is Cascading Rollback?
- How Do I Create An SQL Queries That Show: Student Name, Address, And Contact Information For All Students? Student Name And The Certificate Program For Which They Are Registered Student Name And The Courses For Which They Are Registered?
- I Need To Create A System Where Students Can Register For One Of 5 Certificates, Select Courses, And Obtain A Transcript Of The Grades Received For The Courses. Each Student Can Be Enrolled For Only One Certificate. There Are 4 Courses In Each Cert?
- How The Efficiency And Integrity Of The Data Is Maintained At All Times Although The Database Is Used By Varying Organisational Levels? 2 Examples
- What Is An Attribute In Java?
- How About Links Of London?
- When You Create A New COM Component In Visual Basic, You Choose The Following Template?
- What Parts Of Wordpad?
- What Is Indexed File Organization?

New Comment - Comments are editable for 5 min.