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

dynamic array

P: n/a
Hi,
we can do
Dim arr() As Integer = {1, 3, 5, 6}

Is there any way can assign with ReDim as well? I don't need to preserve the
value.

Another question, is there anyway that I can make (normal Dim) the elements
{...} dynamic based on variable (late-binding)? I would need all of them to
have the same value (variable), but I don't know the number of elements until
run-time.

thanks
Eugene
Nov 21 '05 #1
Share this Question
Share on Google+
1 Reply

P: n/a
>we can do
Dim arr() As Integer = {1, 3, 5, 6}

Is there any way can assign with ReDim as well? I don't need to preserve the
value.
arr = New Integer() {2, 4}

is effectively the same as ReDim.

Another question, is there anyway that I can make (normal Dim) the elements
{...} dynamic based on variable (late-binding)? I would need all of them to
have the same value (variable), but I don't know the number of elements until
run-time.


If I understand the question correctly; no, but you can just as easily
do it with a loop

arr = New Integer(n - 1) {}
For i As Integer = 0 To n - 1
arr(i) = SomeDynamicValue
Next


Mattias

--
Mattias Sjögren [MVP] mattias @ mvps.org
http://www.msjogren.net/dotnet/ | http://www.dotnetinterop.com
Please reply only to the newsgroup.
Nov 21 '05 #2

This discussion thread is closed

Replies have been disabled for this discussion.