this is for ken tucker: How To Create A Collection Class with VB.NET

S

Supra

hi ken tucker,
how will i do in vb.net? in vb6 i have no problem. i have rewritten
in vb.net but i got white blank form. i am doing irc chat project
similar mirc chat.
in vb6 class module (not module module)

Public varNewChannel as Collection

Public Property Get NewChannel () as Collection
Set NewChannel = varNewChannel
End Property

Public Property Let NewChannel(byval var as Object)
varNewChannel = var
End Propewrty

Public Sub fChannel(byval sText as string)
Dim m_Chan as New frmChannel
m_Chan.Text= sText
varNewChannel.Item.Add m_Chan,sText
m_Chan.Tag = sText
End Sub

Public Class_Intialize()
Set Me.NewChannel = New Collection =====> that is the only problem
like public sub New() in vb.net
End Sub


in vb.net, do i have to put namespace" import System.Collection"?

regards,
supra
 
K

Ken Tucker [MVP]

Hi,

Here is a custom collection I wrote as an example.

Public Class NewsGroupMessageCollection
Inherits System.Collections.CollectionBase

Public Sub Add(ByVal value As NNTP.NewsGroupMessage)
list.Add(value)
End Sub
Public Sub Remove(ByVal Index As Integer)
If Index > Count - 1 Or Index < 0 Then
Throw New Exception("Invalid Index")
Else
list.RemoveAt(Index)
End If
End Sub
Public ReadOnly Property Item(ByVal Index As Integer) As
NNTP.NewsGroupMessage
Get
Return CType(list.Item(Index), NNTP.NewsGroupMessage)
End Get
End Property

End Class

For more info see here.
ms-help://MS.VSCC/MS.MSDNQTR.2004OCT.1033/vbcon/html/vaconCreatingYourOwnCollectionClass.htm


Ken
----------------------------
hi ken tucker,

how will i do in vb.net? in vb6 i have no problem. i have rewritten in
vb.net but i got white blank form. i am doing irc chat project similar mirc
chat.
in vb6 class module (not module module)

Public varNewChannel as Collection

Public Property Get NewChannel () as Collection
Set NewChannel = varNewChannel
End Property

Public Property Let NewChannel(byval var as Object)
varNewChannel = var
End Propewrty

Public Sub fChannel(byval sText as string)
Dim m_Chan as New frmChannel
m_Chan.Text= sText
varNewChannel.Item.Add m_Chan,sText
m_Chan.Tag = sText
End Sub

Public Class_Intialize()
Set Me.NewChannel = New Collection =====> that is the only problem like
public sub New() in vb.net
End Sub


in vb.net, do i have to put namespace" import System.Collection"?

regards,
supra
 
K

Ken Tucker [MVP]

Hi,

http://msdn.microsoft.com/library/d.../html/vaconCreatingYourOwnCollectionClass.asp

Ken
-----------------
Hi,

Here is a custom collection I wrote as an example.

Public Class NewsGroupMessageCollection
Inherits System.Collections.CollectionBase

Public Sub Add(ByVal value As NNTP.NewsGroupMessage)
list.Add(value)
End Sub
Public Sub Remove(ByVal Index As Integer)
If Index > Count - 1 Or Index < 0 Then
Throw New Exception("Invalid Index")
Else
list.RemoveAt(Index)
End If
End Sub
Public ReadOnly Property Item(ByVal Index As Integer) As
NNTP.NewsGroupMessage
Get
Return CType(list.Item(Index), NNTP.NewsGroupMessage)
End Get
End Property

End Class

For more info see here.
ms-help://MS.VSCC/MS.MSDNQTR.2004OCT.1033/vbcon/html/vaconCreatingYourOwnCollectionClass.htm


Ken
----------------------------
hi ken tucker,

how will i do in vb.net? in vb6 i have no problem. i have rewritten in
vb.net but i got white blank form. i am doing irc chat project similar mirc
chat.
in vb6 class module (not module module)

Public varNewChannel as Collection

Public Property Get NewChannel () as Collection
Set NewChannel = varNewChannel
End Property

Public Property Let NewChannel(byval var as Object)
varNewChannel = var
End Propewrty

Public Sub fChannel(byval sText as string)
Dim m_Chan as New frmChannel
m_Chan.Text= sText
varNewChannel.Item.Add m_Chan,sText
m_Chan.Tag = sText
End Sub

Public Class_Intialize()
Set Me.NewChannel = New Collection =====> that is the only problem like
public sub New() in vb.net
End Sub


in vb.net, do i have to put namespace" import System.Collection"?

regards,
supra
 
C

Cor Ligthert

Ken,

I think the same however in other message he write that he "needs" that
collection for his Chat program as it is now in VB6.

That are two different goals in my opinion. Learning how to make your own
collection class and how to make a good solution.

(Ken) I hope you see that my discussion with you is indirect to Supra

:)

Cor
 
K

Ken Tucker [MVP]

Hi,

I do see that. The hashtable might also be a good solution for his
needs because he can look up values quickly.

Ken
-------------------
Ken,

I think the same however in other message he write that he "needs" that
collection for his Chat program as it is now in VB6.

That are two different goals in my opinion. Learning how to make your own
collection class and how to make a good solution.

(Ken) I hope you see that my discussion with you is indirect to Supra

:)

Cor
 

Ask a Question

Want to reply to this thread or ask your own question?

You'll need to choose a username for the site, which only take a couple of moments. After that, you can post your question and our members will help you out.

Ask a Question

Top