[RESOLVED] declaring an array of unfixed size (newby :) )
Hi all.
should be an easy one hopefully
i just want to declare a (id call it dynamic, grows and shrinks according to its contents) array
Dim data_file() As String
but then how do i deal with this array?
assign elements to it etc
you dont seem to be able to handle it like a
Code:
Dim data_file(10000) As String
array.
cheers
Re: declaring an array of unfixed size (newby :) )
If you want to be able to remove and add elements from the array you should consider using a Collection or List instead.
You shouldnt be declaring a larger array than needed, for example if I want to fill a process array with the processes on the computer I could in theory do this:
VB Code:
Dim p(1000) as Process
p = Process.GetProcesses()
But that would be totally unnecessary. If you dont assign any upper bound value to the array it will resize itself to the needed size:
VB Code:
Dim p() as Process
p = Process.GetProcesses()
But like I said it looks to me like you should be using a collection or list instead.
Re: declaring an array of unfixed size (newby :) )
Collections are the best solution.
Code:
dim data_file as arrayList = new ArrayList()
and then play with the properties and methods of the class
Re: declaring an array of unfixed size (newby :) )
okay guys, thanks for that
il start taking a little look into that.
cheers for the prompt response
Andy