|
-
Mar 18th, 2007, 12:44 PM
#1
Thread Starter
Member
[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
-
Mar 18th, 2007, 01:01 PM
#2
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.
-
Mar 18th, 2007, 01:13 PM
#3
Fanatic Member
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
-
Mar 18th, 2007, 02:24 PM
#4
Thread Starter
Member
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
Posting Permissions
- You may not post new threads
- You may not post replies
- You may not post attachments
- You may not edit your posts
-
Forum Rules
|
Click Here to Expand Forum to Full Width
|