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.
You want to create an external class, or class library to the get the list data, and have both forms call that function.
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
精彩评论