|
web
newsgroups
|
|||||||||||||||||||||||
|
|||||||||||||||||||||||
class inside a class?Class A
. Function A1() . Class B Function test() How do I reference FunctionA1 here? End Function End Class End Class Would you not have to make a class A within class b
<written in text not editor > Dim cHi As New Class A cHi.A1 ---- Or... Make the function public ? ***Im new at this too but maybe you have to even do a Dim cClassB As New Class B '(within Class A) and call Class b from within A ? Whats that function do ? Maybe you just need a module with a public function that can be called from anywhere you want? M. Show quoteHide quote "HockeyFan" <les.stock***@gmail.com> wrote in message news:1162324774.085273.289350@m7g2000cwm.googlegroups.com... > Class A > . > Function A1() > . > Class B > Function test() > How do I reference FunctionA1 here? > End Function > > End Class > End Class > > How do I reference FunctionA1 here? Like any other method, you either need an instance of the containingclass (an A object), or make the method Shared so it can be called witout an instance. Mattias -- Mattias Sjögren [C# MVP] mattias @ mvps.org http://www.msjogren.net/dotnet/ | http://www.dotnetinterop.com Please reply only to the newsgroup. HockeyFan wrote:
> Class A As you would from anywhere. As the method is not static (Shared in VB), > . > Function A1() > . > Class B > Function test() > How do I reference FunctionA1 here? > End Function > > End Class > End Class > you need an instance of the A class to use it. "HockeyFan" <les.stock***@gmail.com> wrote in message Just to add to what other's have said, it looks like from your question that news:1162324774.085273.289350@m7g2000cwm.googlegroups.com... > Class A > . > Function A1() > . > Class B > Function test() > How do I reference FunctionA1 here? > End Function > > End Class > End Class you consider instances of ClassA and ClassB to be somehow related (or even the same thing). They are seperate classes just like any other classes but with some special considerations, eg B can call A's private parts. Show quoteHide quote > Not sure if the below will work or not but if not, I'm sure someone will let
me know! Class A Private C1 as Class A Public Sub New() A = Me End Sub Public Function A1() as Something ... End Function Class B Function test() Dim var as Something = C.A1() End Function End Class End Class > -- Show quoteHide quoteDennis in Houston "Michael C" wrote: > "HockeyFan" <les.stock***@gmail.com> wrote in message > news:1162324774.085273.289350@m7g2000cwm.googlegroups.com... > > Class A > > . > > Function A1() > > . > > Class B > > Function test() > > How do I reference FunctionA1 here? > > End Function > > > > End Class > > End Class > > Just to add to what other's have said, it looks like from your question that > you consider instances of ClassA and ClassB to be somehow related (or even > the same thing). They are seperate classes just like any other classes but > with some special considerations, eg B can call A's private parts. > > > > > > HockeyFan wrote:
> Class A The inner class [instance] requires an instance of the parent object to > . > Function A1() > . > Class B > Function test() > How do I reference FunctionA1 here? > End Function > > End Class > End Class > work with. Generally, I do it this way : Class A Function A1() as whatever End Function Class B ' 'A' can create 'B's, but the Outside World cannot. Friend Sub New( ByVal parent as A ) m_parent = parent End Sub Function test() as whatever Return m_parent.A1() End Function Private m_parent As A = Nothing End Class End Class HTH, Phill W.
system.net.mail
Treeview doubleclick help How to tell .methode with one to take? Is application running? To create an instance of class in VB2005 Help with Vb.net 2002 Update VB6 to VB.NET 2.0 Email Send Animations for games Change color of HideSelection from Grey (Sorry if posted twice, first choked) ATTN: Seth Rowe follow up to startup path posting |
|||||||||||||||||||||||