tags:

views:

86

answers:

2

Hello All.

I am trying to develop a vb programe where i am using List to store data. I want to use all datas saved in that list from another class.

In Class 1, i am trying to include a method that will return my list. And form class 2, i will call that method and get that list.

But code isnt working.

Can anyone plz help. ! ! !

Thanks.

For Example. In class one, Name- Add.vb' My thie method was supposed to return list.

Public Property getList() As List(Of Car)
    Get
        Return CarDetails
    End Get
    Set(ByVal value As List(Of Car))

    End Set
End Property

and In class 2.

Private addobject As Add
Private details As New List(Of Car)

addobject = New Add()

details = addobject.getList()

But I am not getting the list.

A: 

I am not sure this is the problem you are facing, but the getlist in the Add class is a property, not a method. This means that you should not have the trailing paranthesis when calling it. You can change your code into this:

' create a new instance of Add '
Dim addobject As New Add()
' get the list from the property '
Dim details As List(Of Car) = addobject.getlist
Fredrik Mörk
Private details As List(Of Car) = addobject.getlist... This line isnt working. Its saying. "End of statement Expected"....Thanks
ssm
Assuming that the code is located inside a method, it should be `Dim`, not `Private` (my bad; don't write a lot of VB.NET code, and didn't run the code through a compiler before posting it). Updated the answer.
Fredrik Mörk
A: 

You want to create an external class, or class library to the get the list data, and have both forms call that function.

Shawn Simon