Home All Groups Group Topic Archive Search About

How to declare a sub class

Author
20 Nov 2006 5:20 AM
JR
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

Author
20 Nov 2006 5:25 AM
Tom Shelton
JR wrote:
Show quoteHide quote
> 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

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

--
Tom Shelton
Author
20 Nov 2006 11:36 AM
Phill W.
JR wrote:

> I have made a class like
> class MyClass
>     Public MySubClass as new SubClass
> end class
>
> class MySubClass
> 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

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.
Author
20 Nov 2006 12:55 PM
M. Posseth
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]


Show quoteHide quote
"Phill W." wrote:

> JR wrote:
>
> > I have made a class like
> > class MyClass
> >     Public MySubClass as new SubClass
> > end class
> >
> > class MySubClass
> > 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
>
> 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.
>
Author
20 Nov 2006 3:28 PM
Phill W.
M. Posseth wrote:
Show quoteHide quote
> "Phill W." wrote:

>>> 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
>> 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

> 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.
Author
21 Nov 2006 8:45 AM
M. Posseth
Well i see we speak the same language :-)


regards

Michel 




Show quoteHide quote
"Phill W." wrote:

> M. Posseth wrote:
> > "Phill W." wrote:
>
> >>> 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
> >> 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
>
>  > 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.
>
Author
22 Nov 2006 6:38 PM
JR
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


Show quoteHide quote
"M. Posseth" <MPoss***@discussions.microsoft.com> schreef in bericht
news:93C7827E-352E-4CD9-9724-DF5B94DA54A3@microsoft.com...
> Well i see we speak the same language :-)
>
>
> regards
>
> Michel
>
>
>
>
> "Phill W." wrote:
>
>> M. Posseth wrote:
>> > "Phill W." wrote:
>>
>> >>> 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
>> >> 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
>>
>>  > 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.
>>