By using this site, you agree to our updated Privacy Policy and our Terms of Use. Manage your Cookies Settings.
459,504 Members | 1,194 Online
Bytes IT Community
+ Ask a Question
Need help? Post your question and get tips & solutions from a community of 459,504 IT Pros & Developers. It's quick & easy.

How to .... Syntax

P: n/a
I have three classes named: Action, Link, LinkCollection.

Action class represents a row in table called Actions.
Link class represents a row in table called Links.
The Action table is the parent and the Links table is the child.

The LinkCollection class contains a HashTable collection of Link classes.

In my Action class I have a Public member variable called colLinks and a
method to populate it when I populate the Action class:
Public Class Action
Public colLinks = New LinkCollection()
...
Public Function LoadClass
....
GetChildren
End Function
Private Function GetChildren() as Boolean
'Do stuff to populate colLinks LinkCollection class with Link
classes
End Function

End Class

Called from my client application this all works so far:
Dim objAction As Actions
Dim objLink As New Links

objAction = New Actions
objAction.Action_ID = 1
objAction.LoadClass()

The Parent class is populated and its public member colLinks is loaded full
of Link classes.
The problem I'm having is looping through the colLinks collection:
I can't do this:

For Each objLink In objAction.colLinks()
..........Party with each Link class individually
Next

This causes an exception "System.MissingMemberException","No Default member
found for type LinkCollection" on the For Each line.

But I can declare a local object and set it equal to the Action class's
public member:

Dim colPete As LinkCollection
colPete = objAction.colLinks

For Each objLink In objAction.colLinks()
..........Party with each Link class individually
Next

No errors doing this.
What is going on ?? Any thoughts ???

Thanks in Advance.

Pete
Nov 20 '05 #1
Share this Question
Share on Google+
1 Reply


P: n/a
In article <u9**************@TK2MSFTNGP12.phx.gbl>, Pete Mitchell wrote:
I have three classes named: Action, Link, LinkCollection.

Action class represents a row in table called Actions.
Link class represents a row in table called Links.
The Action table is the parent and the Links table is the child.

The LinkCollection class contains a HashTable collection of Link classes.

In my Action class I have a Public member variable called colLinks and a
method to populate it when I populate the Action class:
Public Class Action
Public colLinks = New LinkCollection()
...
Public Function LoadClass
....
GetChildren
End Function
Private Function GetChildren() as Boolean
'Do stuff to populate colLinks LinkCollection class with Link
classes
End Function

End Class

Called from my client application this all works so far:
Dim objAction As Actions
Dim objLink As New Links

objAction = New Actions
objAction.Action_ID = 1
objAction.LoadClass()

The Parent class is populated and its public member colLinks is loaded full
of Link classes.
The problem I'm having is looping through the colLinks collection:
I can't do this:

For Each objLink In objAction.colLinks()
..........Party with each Link class individually
Next

This causes an exception "System.MissingMemberException","No Default member
found for type LinkCollection" on the For Each line.

But I can declare a local object and set it equal to the Action class's
public member:

Dim colPete As LinkCollection
colPete = objAction.colLinks

For Each objLink In objAction.colLinks()
..........Party with each Link class individually
Next

No errors doing this.
What is going on ?? Any thoughts ???

Thanks in Advance.

Pete


Pete,

It might be helpful is you could post a small, but complete working
example of the issue. I'm not sure exactly what your asking, and
normally questions of this nature get answered rather quickly.

--
Tom Shelton
MVP [Visual Basic]
Nov 20 '05 #2

This discussion thread is closed

Replies have been disabled for this discussion.