How do we take any array value without initialization in vb.net?

82 views Asked by At

Like with initialization: We take like:

 Dim a() as integer = {1,2,4,6}

And if i want to print the array list it will be 1 , 2 ,4,6 as output But how can i take any value i.e n value to print n values as output.

1

There are 1 answers

3
Ortund On

Seems to me your best bet will be to add n elements from the array to a second array and print that instead:

Dim a() as integer = {1, 2, 3, 4, 6}

Dim b as new list(of integer)
' Where n is the total number of elements you want to print.
For counter As integer = 0 To n
    b.Add(a(counter))
Next

PrintItems(b)

I haven't worked in VB for nearly 10 years so apologies if my code isn't 100% correct.