Bonjour.
N'y aurait-il pas depuis la VB8 un moyen d'assigner en une seule instruction
l'ensemble des propriétés d'un objet aux propriétés de mêmes noms d'un autre
objet, plutôt que d'écrire la liste fastidieuse :
O2.P1 = O1.P1
O2.P2 = O1.P2
O3.P2 = O1.P3
etc.
Une sorte de MOVE CORRESPONDING en COBOL en quelque sorte.
Il me semble avoir entendu parler de quelque chose de semblable lors d'une
présentation de LINQ, mais le souvenir est trop vague.
Merci de votre aide,
Gilbert 10 1173
On Aug 29, 9:19*am, "Gilbert Tordeur" <gilbert.tord...@orange.fr>
wrote:
Bonjour.
N'y aurait-il pas depuis la VB8 un moyen d'assigner en une seule instruction
l'ensemble des propriétés d'un objet aux propriétés de mêmes noms d'un autre
objet, plutôt que d'écrire la liste fastidieuse :
O2.P1 = O1.P1
O2.P2 = O1.P2
O3.P2 = O1.P3
etc.
Une sorte de MOVE CORRESPONDING en COBOL en quelque sorte.
Il me semble avoir entendu parler de quelque chose de semblable lors d'une
présentation de LINQ, mais le souvenir est trop vague.
Merci de votre aide,
Gilbert
English please?
Thanks,
Seth Rowe [MVP] http://sethrowe.blogspot.com/
Sorry, in English :
Hello,
Is there a way since VB2008 to assign with only one statement all the
properties of an object to the (same name) properties of another object,
instead of coding number of trivial lines like
O2.P1 = O1.P1
O2.P2 = O1.P2
O2.P3 = O1.P3
etc.
Something like a MOVE CORRESPONDING in COBOL.
I think I have heard somethink like this in a LINQ meeting sometime ago, but
I do not remember. Thank you for your help.
Gilbert
On Aug 29, 9:38*am, "Gilbert Tordeur" <gilbert.tord...@orange.fr>
wrote:
Sorry, in English :
Hello,
Is there a way since VB2008 to assign with only one statement all the
properties of an object to the (same name) properties of another object,
instead of coding number of trivial lines like
O2.P1 = O1.P1
O2.P2 = O1.P2
O2.P3 = O1.P3
etc.
Something like a MOVE CORRESPONDING in COBOL.
I think I have heard somethink like this in a LINQ meeting sometime ago, but
I do not remember. Thank you for your help.
Gilbert
I don't think there is a built in method (I could be wrong).
Once upon a time I wrote a piece using Reflection that did this, but
I'm not sure where that code is. Basically you do a GetProperties on
the source class and then you attempt to do a set value for each of
the properties in the destination class, not the cleanest solution,
but it works.
Thanks,
Seth Rowe [MVP] http://sethrowe.blogspot.com/
OK, I think I can do that.
Thank you,
Gilbert
"rowe_newsgroups" <ro********@yahoo.coma écrit dans le message de news: b7**********************************...oglegroups.com...
On Aug 29, 9:38 am, "Gilbert Tordeur" <gilbert.tord...@orange.fr>
wrote:
Sorry, in English :
Hello,
Is there a way since VB2008 to assign with only one statement all the
properties of an object to the (same name) properties of another object,
instead of coding number of trivial lines like
O2.P1 = O1.P1
O2.P2 = O1.P2
O2.P3 = O1.P3
etc.
Something like a MOVE CORRESPONDING in COBOL.
I think I have heard somethink like this in a LINQ meeting sometime ago,
but
I do not remember. Thank you for your help.
Gilbert
I don't think there is a built in method (I could be wrong).
Once upon a time I wrote a piece using Reflection that did this, but
I'm not sure where that code is. Basically you do a GetProperties on
the source class and then you attempt to do a set value for each of
the properties in the destination class, not the cleanest solution,
but it works.
Thanks,
Seth Rowe [MVP] http://sethrowe.blogspot.com/
On Aug 29, 10:05*am, "Gilbert Tordeur" <gilbert.tord...@orange.fr>
wrote:
OK, I think I can do that.
Thank you,
Gilbert
"rowe_newsgroups" <rowe_em...@yahoo.coma écrit dans le message de news:
b736454f-7fbb-420d-b62e-432caf702...@k30g2000hse.googlegroups.com...
On Aug 29, 9:38 am, "Gilbert Tordeur" <gilbert.tord...@orange.fr>
wrote:
Sorry, in English :
Hello,
Is there a way since VB2008 to assign with only one statement all the
properties of an object to the (same name) properties of another object,
instead of coding number of trivial lines like
O2.P1 = O1.P1
O2.P2 = O1.P2
O2.P3 = O1.P3
etc.
Something like a MOVE CORRESPONDING in COBOL.
I think I have heard somethink like this in a LINQ meeting sometime ago,
but
I do not remember. Thank you for your help.
Gilbert
I don't think there is a built in method (I could be wrong).
Once upon a time I wrote a piece using Reflection that did this, but
I'm not sure where that code is. Basically you do a GetProperties on
the source class and then you attempt to do a set value for each of
the properties in the destination class, not the cleanest solution,
but it works.
Thanks,
Seth Rowe [MVP]http://sethrowe.blogspot.com/
I just threw some code onto my blog that should do this. As a warning
it's completely untested! http://sethrowe.blogspot.com/2008/08...ing-class.html
Thanks,
Seth Rowe [MVP] http://sethrowe.blogspot.com/
Gilbert Tordeur wrote:
Is there a way since VB2008 to assign with only one statement all the
properties of an object to the (same name) properties of another
object, instead of coding number of trivial lines like
>O2.P1 = O1.P1 O2.P2 = O1.P2 O2.P3 = O1.P3 etc.
I could be getting the wrong idea, but isn't that what .Clone is for?
Andrew
On Aug 29, 10:33*am, "Andrew Morton" <a...@in-press.co.uk.invalid>
wrote:
Gilbert Tordeur wrote:
Is there a way since VB2008 to assign with only one statement all the
properties of an object to the (same name) properties of another
object, instead of coding number of trivial lines like
O2.P1 = O1.P1
O2.P2 = O1.P2
O2.P3 = O1.P3
etc.
I could be getting the wrong idea, but isn't that what .Clone is for?
Andrew
Clone doesn't work if you want to change class types (which is what I
took as what the OP was looking for). It also will only work with the
class implements ICloneable.
Thanks,
Seth Rowe [MVP] http://sethrowe.blogspot.com/
Andrew,
I think .Clone is for the same class, but if you copy to an object of
another class ?
Regards,
Gilbert
"Andrew Morton" <ak*@in-press.co.uk.invalida écrit dans le message de
news: 6h************@mid.individual.net...
Gilbert Tordeur wrote:
>Is there a way since VB2008 to assign with only one statement all the properties of an object to the (same name) properties of another object, instead of coding number of trivial lines like
>>O2.P1 = O1.P1 O2.P2 = O1.P2 O2.P3 = O1.P3 etc.
I could be getting the wrong idea, but isn't that what .Clone is for?
Andrew
OK, I got it. I will try and let you know.
Regards,
Gilbert
"rowe_newsgroups" <ro********@yahoo.coma écrit dans le message de news: c5**********************************...oglegroups.com...
On Aug 29, 10:05 am, "Gilbert Tordeur" <gilbert.tord...@orange.fr>
wrote:
OK, I think I can do that.
Thank you,
Gilbert
"rowe_newsgroups" <rowe_em...@yahoo.coma écrit dans le message de news:
b736454f-7fbb-420d-b62e-432caf702...@k30g2000hse.googlegroups.com...
On Aug 29, 9:38 am, "Gilbert Tordeur" <gilbert.tord...@orange.fr>
wrote:
Sorry, in English :
Hello,
Is there a way since VB2008 to assign with only one statement all the
properties of an object to the (same name) properties of another object,
instead of coding number of trivial lines like
O2.P1 = O1.P1
O2.P2 = O1.P2
O2.P3 = O1.P3
etc.
Something like a MOVE CORRESPONDING in COBOL.
I think I have heard somethink like this in a LINQ meeting sometime ago,
but
I do not remember. Thank you for your help.
Gilbert
I don't think there is a built in method (I could be wrong).
Once upon a time I wrote a piece using Reflection that did this, but
I'm not sure where that code is. Basically you do a GetProperties on
the source class and then you attempt to do a set value for each of
the properties in the destination class, not the cleanest solution,
but it works.
Thanks,
Seth Rowe [MVP]http://sethrowe.blogspot.com/
I just threw some code onto my blog that should do this. As a warning
it's completely untested! http://sethrowe.blogspot.com/2008/08...ing-class.html
Thanks,
Seth Rowe [MVP] http://sethrowe.blogspot.com/
Gilbert Tordeur wrote:
Is there a way since VB2008 to assign with only one statement all the
properties of an object to the (same name) properties of another object,
instead of coding number of trivial lines like
>O2.P1 = O1.P1 O2.P2 = O1.P2 O2.P3 = O1.P3 etc.
To copy absolutely /everything/, implement a Clone() method.
To create one object [class] based on another object [class], create the
relevant constructor in the second class:
Class C1
Public Sub New()
End Sub
End Class
Class C2
Public Sub New( ByVal source as C1 )
End Sub
End Class
Dim o1 as New C1()
Dim o2 as New C2( o1 )
Even if there /was/ a way of doing this "automagically", personally, I'd
avoid it; I like to [think I] know what my code is actually doing! :-)
YMMV.
HTH,
Phill W. This thread has been closed and replies have been disabled. Please start a new discussion. Similar topics
by: Arthur Dent |
last post by:
Does anyone know where i can find a decently thorough list of the language
changes in VB2008, such as the new If() function?
All i can seem to find through search engines, most of the articles...
|
by: Arthur Dent |
last post by:
I am trying to make a VB2008 Express winforms project, and edit the form.
However, when i try to open the form, i get this error:
..NET Framework 2.0 update not found. The win32manifest will not...
|
by: Academia |
last post by:
I have a computer at home with a (slow) dialup connection and a computer at
school with a fast connection.
I want to go there (it is not close) and down load Vb2008 express, burn it
into a CD,...
|
by: Galen Somerville |
last post by:
My graphics involves a lot of line drawings in a short period of time. I
have all the graphics in a separate module.
I repeatedly get the pixel data from a USB device, draw the requisite
traces,...
|
by: Scott Gravenhorst |
last post by:
Windows XP SP3
My application is set to open a SaveFile dialog when an exit is
requested. When I click the app's close button, the save dialog
opens, but when I click to change the folder, the...
|
by: MichaelH |
last post by:
Are there any definite advantages of VB2008 over VB2005?
Thank in advance.
Michael
|
by: John Whitworth |
last post by:
Hi,
I'm rewriting an old VB6 app of mine in VB2008. All has been going well with
calls to winscard.dll, until I needed to send an array of bytes as part of a
structure. When using a winscard...
|
by: John Dann |
last post by:
Looking to migrate from VB2005 Pro to VB2008. Can anyone
suggest/recommend a VB2008 book that highlights the changes from
earlier versions of VB.Net (VB2003/2005) rather than describing VB2008...
|
by: CloudSolutions |
last post by:
Introduction:
For many beginners and individual users, requiring a credit card and email registration may pose a barrier when starting to use cloud servers. However, some cloud server providers now...
|
by: Faith0G |
last post by:
I am starting a new it consulting business and it's been a while since I setup a new website. Is wordpress still the best web based software for hosting a 5 page website? The webpages will be...
|
by: Charles Arthur |
last post by:
How do i turn on java script on a villaon, callus and itel keypad mobile phone
|
by: aa123db |
last post by:
Variable and constants
Use var or let for variables and const fror constants.
Var foo ='bar';
Let foo ='bar';const baz ='bar';
Functions
function $name$ ($parameters$) {
}
...
|
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...
|
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...
|
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
|
by: nemocccc |
last post by:
hello, everyone, I want to develop a software for my android phone for daily needs, any suggestions?
|
by: Sonnysonu |
last post by:
This is the data of csv file
1 2 3
1 2 3
1 2 3
1 2 3
2 3
2 3
3
the lengths should be different i have to store the data by column-wise with in the specific length.
suppose the i have to...
| |