dynamic array

  • Thread starter Thread starter Guest
  • Start date Start date
G

Guest

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
 
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
 

Ask a Question

Want to reply to this thread or ask your own question?

You'll need to choose a username for the site, which only take a couple of moments. After that, you can post your question and our members will help you out.

Ask a Question

Similar Threads


Back
Top