How to declare a sub class


J

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
 
Ad

Advertisements

T

Tom Shelton

JR said:
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?
 
P

Phill W.

JR said:
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.
 
G

Guest

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

Phill W.

M. Posseth said:
"Phill W." wrote:
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.
 
G

Guest

Well i see we speak the same language :)


regards

Michel




Phill W. said:
M. Posseth said:
"Phill W." wrote:
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.
 
Ad

Advertisements

J

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


M. Posseth said:
Well i see we speak the same language :)


regards

Michel




Phill W. said:
M. Posseth said:
"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.
 

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