|
-
Dec 3rd, 2009, 10:45 PM
#1
Thread Starter
Junior Member
OOP Classes - can't clear list of data saved
Hi, bare with me here
ok I posted on here a while back, like month to 2 months ago about creating an array of data (user inputed data). But was suggested to go the class route. After weeks of lengthly reading came up with a list collection class.
'*********************Device Class*******************
Public Class Device
Private _PosList As List(of Position)
Public Sub New()
_PosList = New List(of Position)
End Sub
Public Property PositionList() As List(Of Position)
Get
Return _PosList
End Get
Set(ByVal value As List(Of Position))
_PosList = value
End Set
End Property
Public Sub AddPosition(ByVal aPos As Position)
_PosList.Add(aPos)
End Sub
End Class
'*********** This is the position class******************
Public Class Position
Private _DataInfo As String
Public Sub New(ByVal info As String)
_DataInfo = info
End Sub
Public Property DataInformation() As String
Get
Return _DataInfo
End Get
Set(ByVal value As String)
_DataInfo = value
End Set
End Property
End Class
'******* Main Form Class *******************************
'In here I then created my objects from the class
Public Class Main
Private DeviceList as New List(of Device)
Private Device1 as New Device()
'Module that creates the objects *******
Private sub MyDevices()
DeviceList.Add(Device1)
Device1.AddPosition(New Position(txtYXD1B1.Text))
End Sub
Private Sub Button_Click(....)
Me.MyDevices()
SomeTextBox.Text = (DeviceList(0).PositionList(0).DataInformation.ToString)
******************************************************
That is pretty much the short version of it. The issue is, when I first enter my data in and click the button. The information is displayed correctly everything is great, but if I decide to change the data and reclick on the button again, the displayed data doesnt update itself. For some reason the data in the object wont clear or reset. I have tried DeviceList.Clear() in my subroutine of MyDevices() before adding my devices and in the button click event before calling MyDevices(). Nothing seems to do it. I have even added a
Public Sub RemovePosition(ByVal aPos As Position)
_PosList.Remove(aPos)
End Sub
and then remove them manually but the same issue occures.
Help.....
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
|