T
Thief_
I want to store data pertaining to a widget in a collection. The widget has
many pproperties, so i created the following class and called it
"clsWatchProperties":
Public Class clsWatchProperties
Private mTopicID As Integer
Private mLastPos As Integer
Private mThisPos As Integer
Private mCancelThisItem As Boolean
Private mHasNewReply As Boolean
Public Property TopicID() As Integer
Get
TopicID = mTopicID
End Get
Set(ByVal Value As Integer)
mTopicID = Value
End Set
End Property
Public Property LastPos() As Integer
Get
LastPos = mLastPos
End Get
Set(ByVal Value As Integer)
mLastPos = Value
End Set
End Property
Public Property ThisPos() As Integer
Get
ThisPos = mThisPos
End Get
Set(ByVal Value As Integer)
mThisPos = Value
End Set
End Property
Public Property CancelThisItem() As Boolean
Get
CancelThisItem = mCancelThisItem
End Get
Set(ByVal Value As Boolean)
mCancelThisItem = Value
End Set
End Property
Public Property HasNewReply() As Boolean
Get
HasNewReply = mHasNewReply
End Get
Set(ByVal Value As Boolean)
mHasNewReply = Value
End Set
End Property
End Class
I then (attempted to) create the collection using the following code:
Private WatchedTopics As New Collection
------
Sub Test
....
Dim WatchTopic As New clsWatchProperties
GetData = CleanString(mLink.ToString, CleanupHTML.ID) ' Retrieves
a 5 digit number which is in a string format
Debug.WriteLine("ID: " & GetData)
If Not FindIfExists(GetData, RowCounter) Then ' This line simply
checks if the object exists in the collection. True is returned if it does.
WatchTopic.TopicID = GetData
WatchTopic.LastPos = RowCounter
WatchTopic.HasNewReply = False
WatchedTopics.Add(WatchTopic,
WatchTopic.TopicID.ToString)
ThisItemIsUpdated = True
End If
If WatchedTopics.Item(GetData).HasNewReply Then
........
End If
I want my collection to look like this:
WatchedTopics("01234").LastPos = 100
WatchedTopics("04321").HasNewReply = False
WatchedTopics("09876").CancelThisItem = True
What I'm ACTUALLY getting is:
- WatchedTopics {Length=1} Microsoft.VisualBasic.Collection
(0) "Empty placeholder to adjust for 1 based array" String
- (1) {Microsoft.VisualBasic.Collection.KeyValuePair}
Microsoft.VisualBasic.Collection.KeyValuePair
- Key "107348" {String} Object
String "107348" String
- Value {rnsVBCityForumListener.clsWatchProperties} Object
- [rnsVBCityForumListener.clsWatchProperties]
{rnsVBCityForumListener.clsWatchProperties}
rnsVBCityForumListener.clsWatchProperties
CancelThisItem False Boolean
HasNewReply False Boolean
LastPos 1 Integer
mCancelThisItem False Boolean
mHasNewReply False Boolean
mLastPos 1 Integer
mThisPos 0 Integer
mTopicID 107348 Integer
ThisPos 0 Integer
TopicID 107348 Integer
(This is a copy and paste of the WatchTopics variable and its structure as
seen in the Watch window)
I think I have stuffed up in my code somewhere but can't figger out where.
Please help me.
many pproperties, so i created the following class and called it
"clsWatchProperties":
Public Class clsWatchProperties
Private mTopicID As Integer
Private mLastPos As Integer
Private mThisPos As Integer
Private mCancelThisItem As Boolean
Private mHasNewReply As Boolean
Public Property TopicID() As Integer
Get
TopicID = mTopicID
End Get
Set(ByVal Value As Integer)
mTopicID = Value
End Set
End Property
Public Property LastPos() As Integer
Get
LastPos = mLastPos
End Get
Set(ByVal Value As Integer)
mLastPos = Value
End Set
End Property
Public Property ThisPos() As Integer
Get
ThisPos = mThisPos
End Get
Set(ByVal Value As Integer)
mThisPos = Value
End Set
End Property
Public Property CancelThisItem() As Boolean
Get
CancelThisItem = mCancelThisItem
End Get
Set(ByVal Value As Boolean)
mCancelThisItem = Value
End Set
End Property
Public Property HasNewReply() As Boolean
Get
HasNewReply = mHasNewReply
End Get
Set(ByVal Value As Boolean)
mHasNewReply = Value
End Set
End Property
End Class
I then (attempted to) create the collection using the following code:
Private WatchedTopics As New Collection
------
Sub Test
....
Dim WatchTopic As New clsWatchProperties
GetData = CleanString(mLink.ToString, CleanupHTML.ID) ' Retrieves
a 5 digit number which is in a string format
Debug.WriteLine("ID: " & GetData)
If Not FindIfExists(GetData, RowCounter) Then ' This line simply
checks if the object exists in the collection. True is returned if it does.
WatchTopic.TopicID = GetData
WatchTopic.LastPos = RowCounter
WatchTopic.HasNewReply = False
WatchedTopics.Add(WatchTopic,
WatchTopic.TopicID.ToString)
ThisItemIsUpdated = True
End If
If WatchedTopics.Item(GetData).HasNewReply Then
........
End If
I want my collection to look like this:
WatchedTopics("01234").LastPos = 100
WatchedTopics("04321").HasNewReply = False
WatchedTopics("09876").CancelThisItem = True
What I'm ACTUALLY getting is:
- WatchedTopics {Length=1} Microsoft.VisualBasic.Collection
(0) "Empty placeholder to adjust for 1 based array" String
- (1) {Microsoft.VisualBasic.Collection.KeyValuePair}
Microsoft.VisualBasic.Collection.KeyValuePair
- Key "107348" {String} Object
String "107348" String
- Value {rnsVBCityForumListener.clsWatchProperties} Object
- [rnsVBCityForumListener.clsWatchProperties]
{rnsVBCityForumListener.clsWatchProperties}
rnsVBCityForumListener.clsWatchProperties
CancelThisItem False Boolean
HasNewReply False Boolean
LastPos 1 Integer
mCancelThisItem False Boolean
mHasNewReply False Boolean
mLastPos 1 Integer
mThisPos 0 Integer
mTopicID 107348 Integer
ThisPos 0 Integer
TopicID 107348 Integer
(This is a copy and paste of the WatchTopics variable and its structure as
seen in the Watch window)
I think I have stuffed up in my code somewhere but can't figger out where.
Please help me.