Home | Contact Us | FAQ | Search & Site Map | Link to Us
Sign In | Join | Other 45 Sites in Network
HomeAnnouncementsFree MagazinesWhite PapersSubmit Content
Discussion GroupsASP.NETWindows FormsLanguages.NET FrameworkVisual Studio.NET
Articles.NET FrameworkASP.NETToolsWindows Forms
.NET DirectoryOpen Source ProjectsUser GroupsWeb Resources
Related Topics
Visual Basic 6SQL ServerMS AccessOther DB ProductsMS Server ProductsMore Topics ...

.NET Forum / Languages / VB.NET / November 2006

Tip: Looking for answers? Try searching our database.

How to declare a sub class

Thread view: 
Enable EMail Alerts  Start New Thread
Thread rating: 
JR - 20 Nov 2006 05:20 GMT
Hi,

I have made a class like
class MyClass
   public declare _AVariable as string
   .........
   Public MySubClass as new SubClass
end class

class MySubClass
   ..............'some declaration
end class

how can I access the class with all its subclasses
so that the subclass cant be assignd to a variable
in a mod
dim sc as mysubclass may not be possible

Jan
Tom Shelton - 20 Nov 2006 05:25 GMT
> Hi,
>
[quoted text clipped - 15 lines]
>
> Jan

I'm not sure I understand what you are asking?  Can you be a little
more specific?

--
Tom Shelton
Phill W. - 20 Nov 2006 11:36 GMT
> I have made a class like
> class MyClass
[quoted text clipped - 8 lines]
> in a mod
> dim sc as mysubclass may not be possible

Depends how the classes are used.  If you're building an assembly and
referencing it from another project, then change the subclass to be
defined with the Friend (assembly) scope.
Your code can use it, but nothing "outside" your assembly can.

Public Class MyClass
End Class

Friend Class MySubClass
End Class

If it's all within the /same/ project, you'll have to resort to nesting
the classes and making the inner, subclass private, as in

Public Class MyClass
   Private Class MySubClass
   End Class
End Class

HTH,
   Phill  W.
M. Posseth - 20 Nov 2006 12:55 GMT
I would like to add

That if you want to access the inner class ,from the outside ,  you should
do so by a property

regards

Michel Posseth [MCP]

> > I have made a class like
> > class MyClass
[quoted text clipped - 30 lines]
> HTH,
>     Phill  W.
Phill W. - 20 Nov 2006 15:28 GMT
>>> how can I access the class with all its subclasses
>>> so that the subclass cant be assignd to a variable
>>> in a mod
>>> dim sc as mysubclass may not be possible

>> Depends how the classes are used.  If you're building an assembly and
>> referencing it from another project, then change the subclass to be
[quoted text clipped - 14 lines]
>>     End Class
>> End Class

> I would like to add that if you want to access the inner class
> from the outside, you should do so by a property.

Michel,

But to do so would also require the /Type/ of that Property to be
exposed, which would make it possible to define a variable /of/ that
Type, which the O.P. wished to avoid.

More generally, though, I agree; the "outer" class should provide a
means of getting hold of an instance/collection of any member class[es].

Regards,
   Phill  W.
M. Posseth - 21 Nov 2006 08:45 GMT
Well i see we speak the same language :-)

regards

Michel  

> >>> how can I access the class with all its subclasses
> >>> so that the subclass cant be assignd to a variable
[quoted text clipped - 34 lines]
> Regards,
>     Phill  W.
JR - 22 Nov 2006 18:38 GMT
thanks
some of this helpt me

but becaurse all the items in the class and subclasses are not menth to be
changed I only use strings and read them from an xml file.
Its only for translation of some texts in the program (multi languages)

Jan

> Well i see we speak the same language :-)
>
[quoted text clipped - 41 lines]
>> Regards,
>>     Phill  W.

Free Magazines

Get these publications absolutely FREE for up to 12 months. There are no hidden fees and no obligation. Simply choose a title, complete the application form and submit it. Read more ...

Oracle MagazineNetwork ComputingComputer WorldBio-IT WorldeWeekInformation WeekInfosecurity
 
Sign In
Join
My Latest Posts
My Monitored Threads
My Blog
My Photo Gallery
My Profile
My Homepage

Start New Thread
Enable EMail Alerts
Rate this Thread



©2008 Advenet LLC   Privacy Policy - Terms of Use
This website includes both content owned or controlled by Advenet as well as content owned or controlled by third parties.