473,394 Members | 2,031 Online
Bytes | Software Development & Data Engineering Community
Post Job

Home Posts Topics Members FAQ

Join Bytes to post your question to a community of 473,394 software developers and data experts.

TypeCasting question ???

Dear all,

I have Class1 which belongs to myAssemby1. Class1 contains
columns structure of a table database as follow:

Class MyCustomer

...... some functoin and variables
Class CustomTable

public ID as long
public Customer as string
public Name as string
end class

end class

then in another assembly I have the same type of
infomation but defined as follow

Class MyBestCustomer

....
end function

...... some functoin and variables
Class BestCustomTable

public ID as long
public Customer as string
public Name as string
end class

end class

How can I update both data class in one shot as following?

MyCustomer.CustomTable = MyBestCustomer.BestCustomTable

I get an error saying "Cannot convert type x to type y"

Do u have any idea or tips how can I perform this inseat
of filling up individuial fields

thnaks for your help
regards

Jul 19 '05 #1
2 1845
Since you are using the same values in both classes, and
the MyBestCustomer class has methods that MyCustomer
class does not, I would change the MyBestCustomer class
as follows:
Assuming both assemblies are in the same project

Public MyBestCustomer
-> inherits MyCustomer

---and---
delete the following lines in MyBestCustomer class:

public ID as long
public Customer as string
public Name as string

this way all 3 variables for both classes are the same
and there is no need to update each seperately.

if possible, make the 3 variables in the MyCustomer class
as Protected instead of Public, to increase security in
your application

hope this helps
Darshan
-----Original Message-----
Dear all,

I have Class1 which belongs to myAssemby1. Class1 containscolumns structure of a table database as follow:

Class MyCustomer

...... some functoin and variables
Class CustomTable

public ID as long
public Customer as string
public Name as string
end class

end class

then in another assembly I have the same type of
infomation but defined as follow

Class MyBestCustomer

....
end function

...... some functoin and variables
Class BestCustomTable

public ID as long
public Customer as string
public Name as string
end class

end class

How can I update both data class in one shot as following?
MyCustomer.CustomTable = MyBestCustomer.BestCustomTable

I get an error saying "Cannot convert type x to type y"

Do u have any idea or tips how can I perform this inseat
of filling up individuial fields

thnaks for your help
regards

.

Jul 19 '05 #2
Thanks for your answer...

Just to clarify a bit, those type class which identify table structure
as MyCustomer will be located in an assembly that will be reference
inside a broject.

Then I have make some test with your suggestion.

I have define MyCustomer variables as protected.
Then I have create class1 which inherits MyCustomer and must fill up
MyCustomer parameter like as follow:
ID=123
Customer="Pipe S.A"
Name="John"

I am actually not able to fill those parameter due to protected keyword
????

Then class 1 should pass those parameter to Class2, for that Class2 as
one contructor like :
new (param as MyBestCustomer.MyCustomer)

then from class1 I write:

dim myCust a new Class2(CLass1.MyCustomer)

How can I fill them up my parameter in class1 to be passed to calss2
then?

thanks for your answer


*** Sent via Developersdex http://www.developersdex.com ***
Don't just participate in USENET...get rewarded for it!
Jul 19 '05 #3

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

Similar topics

3
by: Kapil Khosla | last post by:
Hi, I have been trying to understand this concept for quite sometime now somehow I am missing some vital point. I am new to Object Oriented Programming so maybe thats the reason. I want to...
7
by: Nicolay Korslund | last post by:
Hi! I'm having a little trouble with the typecast operator, can anybody help me with the rules for when the this operator is invoked? In the class 'Test' in the code below, the typecast operator...
2
by: Arun Prasath | last post by:
Hi all, I have the following question regd pointer typecasting. Is the following type of pointer typecasting valid? #define ALLOC(type,num) ((type *)malloc(sizeof(type)*num)) /*begin...
63
by: andynaik | last post by:
Hi, Whenever we type in this code int main() { printf("%f",10); } we get an error. We can remove that by using #pragma directive t direct that to the 8087. Even after that the output is...
11
by: Vinod Patel | last post by:
I have a piece of code : - void *data; ...... /* data initialized */ ...... struct known_struct *var = (struct known_struct*) data; /*typecasting*/ How is this different from simple...
3
by: jdm | last post by:
In the sample code for the SortedList class, I see the use of a string typecasting macro consisting of a single letter "S". i.e.: Sortedlist->Add(S"Keyval one", S"Item one"); Now I have...
7
by: Raghu | last post by:
Hello All, I need some help regarding overloading operation. Is there any way to overload typecasting? I mean if i have a piece of code as below. int a = 2: float b; b = (float)a;
16
by: Abhishek | last post by:
why do I see that in most C programs, pointers in functions are accepted as: int func(int i,(void *)p) where p is a pointer or an address which is passed from the place where it is called. what...
4
by: vivekian | last post by:
Hi, This is the part of the code am trying to compile to : void Server::respondToClient ( std::string response ) { .... .... if ((numbytes = sendto ( sockFd_ , response , sizeof(response)...
12
by: bwaichu | last post by:
What is the best way to handle this warning: warning: cast from pointer to integer of different size I am casting in and out of a function that requires a pointer type. I am casting an...
0
by: ryjfgjl | last post by:
If we have dozens or hundreds of excel to import into the database, if we use the excel import function provided by database editors such as navicat, it will be extremely tedious and time-consuming...
0
by: ryjfgjl | last post by:
In our work, we often receive Excel tables with data in the same format. If we want to analyze these data, it can be difficult to analyze them because the data is spread across multiple Excel files...
0
by: emmanuelkatto | last post by:
Hi All, I am Emmanuel katto from Uganda. I want to ask what challenges you've faced while migrating a website to cloud. Please let me know. Thanks! Emmanuel
1
by: nemocccc | last post by:
hello, everyone, I want to develop a software for my android phone for daily needs, any suggestions?
0
by: Hystou | last post by:
There are some requirements for setting up RAID: 1. The motherboard and BIOS support RAID configuration. 2. The motherboard has 2 or more available SATA protocol SSD/HDD slots (including MSATA, M.2...
0
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
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...
0
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
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...

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.