473,466 Members | 1,369 Online
Bytes | Software Development & Data Engineering Community
Create Post

Home Posts Topics Members FAQ

How we can declare dynamic array in vb.net

How can we declare an array that have not afix length? and can it possible to inserts new itmes to it? as much as we want to enter.

--------------------------------
From: Himmat Solanki

-----------------------
Posted by a user from .NET 247 (http://www.dotnet247.com/)

<Id>p3+b0EIBy0WXeQlqHuKhDA==</Id>
Nov 16 '05 #1
3 9674
"Himmat Solanki via .NET 247" <an*******@dotnet247.com> wrote in
message news:ua*************@TK2MSFTNGP10.phx.gbl...
How can we declare an array that have not afix length? and can it possible
to inserts new itmes to it? as much as we want to enter.


Look at ArrayList. Yes. Yes.

And why do you post a vb.net question to a C# group?

--
--Larry Brasfield
email: do***********************@hotmail.com
Above views may belong only to me.
Nov 16 '05 #2
you declare the array as so:
dim Numbers as int32()

and then you can dnamically change size like so:
redim Numbers(100) ' <producing 101 items as indexes range from 0 to 100

Note: if you want to array to keep the values when you resize it,use:
redim preserve ( ? )

Note: you have to use 'Redim' at least once before accessing the array to
initiate it's size! otherwise an exception is thrown

that's it

--
Message posted via http://www.dotnetmonster.com
Nov 16 '05 #3
Fade BS via DotNetMonster.com <fo***@DotNetMonster.com> wrote:
you declare the array as so:
dim Numbers as int32()

and then you can dnamically change size like so:
redim Numbers(100) ' <producing 101 items as indexes range from 0 to 100

Note: if you want to array to keep the values when you resize it,use:
redim preserve ( ? )

Note: you have to use 'Redim' at least once before accessing the array to
initiate it's size! otherwise an exception is thrown


You can't do that in C#, however, and it's not *actually* changing the
size of the array - it's creating a new arrray and copying the old
data, which is inefficient if you do it often.

--
Jon Skeet - <sk***@pobox.com>
http://www.pobox.com/~skeet
If replying to the group, please do not mail me too
Nov 16 '05 #4

This thread has been closed and replies have been disabled. Please start a new discussion.

Similar topics

2
by: Secondpost | last post by:
I need to use a calender object with a dynamic form i.e. when a new row of fields is created using Javascript a calender button appears aswell. The problem is if I need to declare the following...
6
by: Vasileios Zografos | last post by:
Hello, I have a function that generates some values (e.g. vertices in 2d space) the number of which I dont know. So, it could generate 20 vertices, 100 vertices, or even 1 vertex. void...
5
by: meyousikmann | last post by:
I am having a little trouble with dynamic memory allocation. I am trying to read a text file and put the contents into a dynamic array. I know I can use vectors to make this easier, but it has to...
19
by: Geetesh | last post by:
Recently i saw a code in which there was a structer defination similar as bellow: struct foo { int dummy1; int dummy2; int last }; In application the above array is always allocated at...
6
by: Materialised | last post by:
Hi Everyone, I apologise if this is covered in the FAQ, I did look, but nothing actually stood out to me as being relative to my subject. I want to create a 2 dimensional array, a 'array of...
4
by: Linda | last post by:
How can I declare a two dimention array of character with dynamical first dimention and static second dimention using mix of pointer* and . I think "char *A" means first dimention is static and...
5
by: Jiggaz | last post by:
Hi, Look my stored procedure : __________________ ALTER PROCEDURE dbo.CreateAccount @Nickname varchar(30), @Password varchar(15), @Email varchar(50), @Date datetime,
6
by: John Bailo | last post by:
I created a sproc with 3 input parameters and one output parameter. I want to test it in the "Run SQL Scripts" app of Navigator. I wrote this code: DECLARE RTNDATE CHAR(10) DEFAULT ''; CALL...
4
by: ottawajn | last post by:
Hi, There, I want to declare a two-dimension array by "float coeftemp1 ;" in Dev c++. It doesn't work. But, if I change it to "float coeftemp1 ;". It works. Could any one know the reason? ...
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:
There are some requirements for setting up RAID: 1. The motherboard and BIOS support RAID configuration. 2. The motherboard has 2 or more available SATA protocol SSD/HDD slots (including MSATA, M.2...
0
marktang
by: marktang | last post by:
ONU (Optical Network Unit) is one of the key components for providing high-speed Internet services. Its primary function is to act as an endpoint device located at the user's premises. However,...
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
jinu1996
by: jinu1996 | last post by:
In today's digital age, having a compelling online presence is paramount for businesses aiming to thrive in a competitive landscape. At the heart of this digital strategy lies an intricately woven...
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...
0
agi2029
by: agi2029 | last post by:
Let's talk about the concept of autonomous AI software engineers and no-code agents. These AIs are designed to manage the entire lifecycle of a software development project—planning, coding, testing,...
0
by: conductexam | last post by:
I have .net C# application in which I am extracting data from word file and save it in database particularly. To store word all data as it is I am converting the whole word file firstly in HTML and...
0
by: adsilva | last post by:
A Windows Forms form does not have the event Unload, like VB6. What one acts like?

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.