473,503 Members | 1,697 Online
Bytes | Software Development & Data Engineering Community
+ Post

Home Posts Topics Members FAQ

How to equal sub class from base class

I have an instance B of class C1. How can i let variable
BB which class inherits from C1 equal from B in VB.NET?

For example:

Public Class C1
' ...
End Class

Public Class CC1
Inherits C1
' ...
End Class

Public Sub Main()
Dim B as new C1;
Dim BB as CC1;

' How to realize BB = B?

End Sub

My mail address is: xu********@hotmail.com

Nov 20 '05 #1
3 1024
If TypeOf CC Is BB

Regards - OHM

Steven.Xu wrote:
I have an instance B of class C1. How can i let variable
BB which class inherits from C1 equal from B in VB.NET?

For example:

Public Class C1
' ...
End Class

Public Class CC1
Inherits C1
' ...
End Class

Public Sub Main()
Dim B as new C1;
Dim BB as CC1;

' How to realize BB = B?

End Sub

My mail address is: xu********@hotmail.com


--
Best Regards - OHM

O_H_M{at}BTInternet{dot}com
Nov 20 '05 #2
You can't assign a base class instance to a derived class instance because
the derived class hasn't been created, but you can do the opposite:

e.g.

------------------

Public Class C1
' ...
End Class

Public Class CC1
Inherits C1
' ...
End Class

Public Sub Main()
Dim B as C1
Dim BB as New CC1

B = BB

End Sub

-----------------

See http://tinyurl.com/39jju or

http://groups.google.com/groups?hl=e...erived%2Bclass
for a longer explanation
"Steven.Xu" <xu********@hotmail.com> wrote in message
news:04****************************@phx.gbl...
I have an instance B of class C1. How can i let variable
BB which class inherits from C1 equal from B in VB.NET?

For example:

Public Class C1
' ...
End Class

Public Class CC1
Inherits C1
' ...
End Class

Public Sub Main()
Dim B as new C1;
Dim BB as CC1;

' How to realize BB = B?

End Sub

My mail address is: xu********@hotmail.com

Nov 20 '05 #3
Damn, I missed the absence of the 'New' keyword. Well spotted CM.

Regards - OHM

Codemonkey wrote:
You can't assign a base class instance to a derived class instance
because the derived class hasn't been created, but you can do the
opposite:

e.g.

------------------

Public Class C1
' ...
End Class

Public Class CC1
Inherits C1
' ...
End Class

Public Sub Main()
Dim B as C1
Dim BB as New CC1

B = BB

End Sub

-----------------

See http://tinyurl.com/39jju or

http://groups.google.com/groups?hl=e...erived%2Bclass

for a longer explanation
"Steven.Xu" <xu********@hotmail.com> wrote in message
news:04****************************@phx.gbl...
I have an instance B of class C1. How can i let variable
BB which class inherits from C1 equal from B in VB.NET?

For example:

Public Class C1
' ...
End Class

Public Class CC1
Inherits C1
' ...
End Class

Public Sub Main()
Dim B as new C1;
Dim BB as CC1;

' How to realize BB = B?

End Sub

My mail address is: xu********@hotmail.com


--
Best Regards - OHM

O_H_M{at}BTInternet{dot}com
Nov 20 '05 #4

This thread has been closed and replies have been disabled. Please start a new discussion.

Similar topics

8
2841
by: Bryan Parkoff | last post by:
I find an interesting issue that one base class has only one copy for each derived class. It looks like that one base class will be copied into three base classes while derived class from base...
4
3600
by: Eric Lilja | last post by:
Hello, I've made a templated class Option (a child of the abstract base class OptionBase) that stores an option name (in the form someoption=) and the value belonging to that option. The value is...
3
2204
by: Massimiliano Alberti | last post by:
Can someone check this? If it's OK, you can use however you want... :-) It should search for an element in an array and, if it can't find it, return the next element. key is what you are...
7
6594
by: Baski | last post by:
Base class: class AssetBase { string _clli; public string CLLI { get
5
3140
by: Andy | last post by:
Hi all, I have a site with the following architecture: Common.Web.dll - Contains a CommonPageBase class which inherits System.Web.UI.Page myadd.dll - Contains PageBase which inherits...
9
1785
by: Larry Woods | last post by:
I have a method in my base class that I want ALL derived classes to use. But, I find that I can create a "Shadow" method in my derived class that "overrides" the method in my base class. Can't...
4
1576
by: FacultasNetDeveloper | last post by:
I am extending FileSystemInfo class so that I can Implement Icomparable. My custom class looks like: Class FSFileSystemInfo Inherits FileSystemInfo : Implements Icomparable Function...
17
4492
by: Mark A | last post by:
DB2 8.2 for Linux, FP 10 (also performs the same on DB2 8.2 for Windoes, FP 11). Using the SAMPLE database, tables EMP and EMLOYEE. In the followng stored procedure, 2 NULL columns (COMM) are...
1
1735
by: FAQ server | last post by:
----------------------------------------------------------------------- FAQ Topic - Why does 1+1 equal 11? or How do I convert a string to a number?...
0
7199
marktang
by: marktang | last post by:
ONU (Optical Network Unit) is one of the key components for providing high-speed Internet services. Its primary function is to act as an endpoint device located at the user's premises. However,...
0
7273
Oralloy
by: Oralloy | last post by:
Hello folks, I am unable to find appropriate documentation on the type promotion of bit-fields when using the generalised comparison operator "<=>". The problem is that using the GNU compilers,...
0
7322
jinu1996
by: jinu1996 | last post by:
In today's digital age, having a compelling online presence is paramount for businesses aiming to thrive in a competitive landscape. At the heart of this digital strategy lies an intricately woven...
1
6982
by: Hystou | last post by:
Overview: Windows 11 and 10 have less user interface control over operating system update behaviour than previous versions of Windows. In Windows 11 and 10, there is no way to turn off the Windows...
1
5000
isladogs
by: isladogs | last post by:
The next Access Europe User Group meeting will be on Wednesday 1 May 2024 starting at 18:00 UK time (6PM UTC+1) and finishing by 19:30 (7.30PM). In this session, we are pleased to welcome a new...
0
3150
by: adsilva | last post by:
A Windows Forms form does not have the event Unload, like VB6. What one acts like?
0
1501
by: 6302768590 | last post by:
Hai team i want code for transfer the data from one system to another through IP address by using C# our system has to for every 5mins then we have to update the data what the data is updated ...
1
731
muto222
by: muto222 | last post by:
How can i add a mobile payment intergratation into php mysql website.
0
374
bsmnconsultancy
by: bsmnconsultancy | last post by:
In today's digital era, a well-designed website is crucial for businesses looking to succeed. Whether you're a small business owner or a large corporation in Toronto, having a strong online presence...

By using Bytes.com and it's services, you agree to our Privacy Policy and Terms of Use.

To disable or enable advertisements and analytics tracking please visit the manage ads & tracking page.