Object and Class Problem

kiz

New member
Joined
Sep 16, 2008
Messages
2
Programming Experience
Beginner
Hi,
I am creating a small application to teach myself some vb.net. The application just adds, view, deletes a customers. The info is not goin to be saved to file yet so I'm just concentrating on getting the application working. Well to my problem. I have a class called Customer and it contains Name, address etc. I can create one instance of the class when i run my application but I want to be able to create mulitple instances of the class everytime the user clicks add. I tried to create an array such as Dim Customer(20) As New Customer but got and error telling me that isnt possible. Can anyone help, is there a better way.
Thanks
 
Hello.

Your definition of the array is wrong. An Array consists of each separate item.

VB.NET:
'can't work
Dim customers(20) as New Customer

'this will work
Dim customers(20) as Customer

customers(0) = New Customer
...

I'd suggest that you use an ArrayList instead:
VB.NET:
Dim list as new ArrayList()

list.add(New Customer)
list(0).whatEverPropertyYouHave = newValue
...

Bobby
 
Back
Top