473,651 Members | 3,093 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********@hotm ail.com

Nov 20 '05 #1
3 1035
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********@hotm ail.com


--
Best Regards - OHM

O_H_M{at}BTInte rnet{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********@hot mail.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********@hotm ail.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********@hot mail.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********@hotm ail.com


--
Best Regards - OHM

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

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

Similar topics

8
2851
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 class is executed. It means that three derived classes are pointed to a separated copy of base class. I do not allow second and third copy of base class to be created, but it must remain only first copy of base class. It allows three derived...
4
3619
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 of the type the object is instantiated with. In my test program I have Option<std::string> and Option<long>. Here's the code for OptionBase and Option along with a small helper function. In the code are comments describing my problem, look closely...
3
2217
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 searching, in a *base array of LONG with num elements. After some tests it seems to work well (the original version was filled with ASSERTs) (I will use this function in a bigger look-for-or-insert function) Some notes: The function returns the index...
7
6613
by: Baski | last post by:
Base class: class AssetBase { string _clli; public string CLLI { get
5
3153
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 CommonPageBase - Contains myPage which inherits PageBase Each of these classes overrides OnInit and ties an event handler
9
1794
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 figure out what attribute to put on the base class method to prevent this. TIA, Larry Woods
4
1585
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 CompareTo(ByVal o As Object) As Integer _ Implements IComparable.CompareTo My issue comes when I try to set an instance of FSFileSystemInfo to an object that is FileSystemInfo type. Such as:
17
4517
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 selected into 2 different SP variables and compared for equal. They are both NULL, but do not compare as equal. When the Not NULL columns (SALARY) are compared, they do compare as equal.
1
1741
by: FAQ server | last post by:
----------------------------------------------------------------------- FAQ Topic - Why does 1+1 equal 11? or How do I convert a string to a number? ----------------------------------------------------------------------- Variables are not typed; their values are. The conversion between a string and a number happens automatically. Since plus (` + `) is also used as in string concatenation, ` '1' + 1 ` is equal to ` '11' `. The string...
0
8367
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, people are often confused as to whether an ONU can Work As a Router. In this blog post, we’ll explore What is ONU, What Is Router, ONU & Router’s main usage, and What is the difference between ONU and Router. Let’s take a closer look ! Part I. Meaning of...
0
8279
by: Hystou | last post by:
Most computers default to English, but sometimes we require a different language, especially when relocating. Forgot to request a specific language before your computer shipped? No problem! You can effortlessly switch the default language on Windows 10 without reinstalling. I'll walk you through it. First, let's disable language synchronization. With a Microsoft account, language settings sync across devices. To prevent any complications,...
0
8811
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, it seems that the internal comparison operator "<=>" tries to promote arguments from unsigned to signed. This is as boiled down as I can make it. Here is my compilation command: g++-12 -std=c++20 -Wnarrowing bit_field.cpp Here is the code in...
0
7302
agi2029
by: agi2029 | last post by:
Let's talk about the concept of autonomous AI software engineers and no-code agents. These AIs are designed to manage the entire lifecycle of a software development project—planning, coding, testing, and deployment—without human intervention. Imagine an AI that can take a project description, break it down, write the code, debug it, and then launch it, all on its own.... Now, this would greatly impact the work of software developers. The idea...
1
6160
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 presenter, Adolph Dupré who will be discussing some powerful techniques for using class modules. He will explain when you may want to use classes instead of User Defined Types (UDT). For example, to manage the data in unbound forms. Adolph will...
0
5619
by: conductexam | last post by:
I have .net C# application in which I am extracting data from word file and save it in database particularly. To store word all data as it is I am converting the whole word file firstly in HTML and then checking html paragraph one by one. At the time of converting from word file to html my equations which are in the word document file was convert into image. Globals.ThisAddIn.Application.ActiveDocument.Select();...
0
4145
by: TSSRALBI | last post by:
Hello I'm a network technician in training and I need your help. I am currently learning how to create and manage the different types of VPNs and I have a question about LAN-to-LAN VPNs. The last exercise I practiced was to create a LAN-to-LAN VPN between two Pfsense firewalls, by using IPSEC protocols. I succeeded, with both firewalls in the same network. But I'm wondering if it's possible to do the same thing, with 2 Pfsense firewalls...
1
2703
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 we have to send another system
1
1914
muto222
by: muto222 | last post by:
How can i add a mobile payment intergratation into php mysql website.

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.