Variable array length

  • Thread starter Thread starter portroe
  • Start date Start date
P

portroe

by the way,

how do you deal with a variable array lenth, for example if the array
depends on the number of years 'input' by the user,

Dim Years(?) As Integer

thanks
 
something like this?

Public x As Integer

'Program to calculate the number of years
x = InputStartingYear - InputFinalYear

'redim
ReDim Year(x)
 
Hi Portroe,

I think it is better to use for a single dimension dynaminic array the
arraylist, for a two dimension the datatable and for a threedimension the
dataset.

It is all build in why not use it?

Cor
 
portroe said:
something like this?

Public x As Integer

'Program to calculate the number of years
x = InputStartingYear - InputFinalYear

'redim
ReDim Year(x)

Did you test it?
 
* portroe said:
how do you deal with a variable array lenth, for example if the array
depends on the number of years 'input' by the user,

Dim Years(?) As Integer

'Dim Years(Lenght - 1) As Integer' will create an array with indices 0,
1, ..., Length - 1.
 
* portroe said:
something like this?

Public x As Integer

'Program to calculate the number of years
x = InputStartingYear - InputFinalYear

'redim
ReDim Year(x)

Why not test it yourself?
 
thanks I will test, I just have the bad habit of working on multiple
parts at once, therfore making testing difficult :-(
 
I usually use an ArrayList to build an array:

Dim al As New ArrayList
al.Add("test1")
al.Add("test2")
Return al.ToArray(GetType(String))

The last line returns an Array of strings.

--
Greetz

Jan Tielens
________________________________
Read my weblog: http://weblogs.asp.net/jan
 
* portroe said:
thanks I will test, I just have the bad habit of working on multiple
parts at once, therfore making testing difficult :-(

Who doesn't know this problem...

:-(
 
Back
Top