By using this site, you agree to our updated Privacy Policy and our Terms of Use. Manage your Cookies Settings.
444,041 Members | 1,046 Online
Bytes IT Community
+ Ask a Question
Need help? Post your question and get tips & solutions from a community of 444,041 IT Pros & Developers. It's quick & easy.

vb.net array

P: n/a
how to declare an array with dynamic lenght

dim arr() as string

arr = New String(dt.Columns.Count)

some thing like this ...but this give error

regards

vips



Nov 21 '05 #1
Share this Question
Share on Google+
3 Replies


P: n/a
Vips,

In the sample you are asking it, I would just create it new everytime.

dim arr(dt.Columns.Count-1) as string

Normally for a dynamic array you could use the arraylist or any other
dynamic arrayclass

http://msdn.microsoft.com/library/de...classtopic.asp

I hope this helps,

Cor


Nov 21 '05 #2

P: n/a
excellent Cor !!!
it may be easy, but I couldnt find the proper syntax, Now I have it.
thanks a lot .

Vips

"Cor Ligthert" <no************@planet.nl> wrote in message
news:OE**************@TK2MSFTNGP10.phx.gbl...
Vips,

In the sample you are asking it, I would just create it new everytime.

dim arr(dt.Columns.Count-1) as string

Normally for a dynamic array you could use the arraylist or any other
dynamic arrayclass

http://msdn.microsoft.com/library/de...classtopic.asp
I hope this helps,

Cor


Nov 21 '05 #3

P: n/a
"vips" <yp**@hotmail.com> schrieb:
how to declare an array with dynamic lenght

dim arr() as string

arr = New String(dt.Columns.Count)

\\\
arr = New String(dt.Columns.Count - 1) {}
///

- or -

\\\
ReDim arr(dt.Columns.Count - 1)
///

If you want to original content of the array to be copied to the new/resized
array, you can use 'ReDim Preserve'.

--
M S Herfried K. Wagner
M V P <URL:http://dotnet.mvps.org/>
V B <URL:http://classicvb.org/petition/>

Nov 21 '05 #4

This discussion thread is closed

Replies have been disabled for this discussion.