Which vb.net object is the best match for the vb6 collection class?
Specifically, I would like to be able to access the Item property with an
index or a key string.
I wrote my own class that inherits from the collectionbase and uses an
arraylist to hold values, but i'm missing the Item(string) property. I
suppose I could iterate thru the collection and look for a string match, but
I thought there might be an easier way.
Thanks,
Craig 34 5499
Hi,
Take a look at the hashtable.
Ken
---------------
"Craig Buchanan" <so*****@microsoft.com> wrote in message
news:e9*************@TK2MSFTNGP12.phx.gbl... Which vb.net object is the best match for the vb6 collection class? Specifically, I would like to be able to access the Item property with an index or a key string.
I wrote my own class that inherits from the collectionbase and uses an arraylist to hold values, but i'm missing the Item(string) property. I suppose I could iterate thru the collection and look for a string match,
but I thought there might be an easier way.
Thanks,
Craig
Hi,
Take a look at the hashtable.
Ken
---------------
"Craig Buchanan" <so*****@microsoft.com> wrote in message
news:e9*************@TK2MSFTNGP12.phx.gbl... Which vb.net object is the best match for the vb6 collection class? Specifically, I would like to be able to access the Item property with an index or a key string.
I wrote my own class that inherits from the collectionbase and uses an arraylist to hold values, but i'm missing the Item(string) property. I suppose I could iterate thru the collection and look for a string match,
but I thought there might be an easier way.
Thanks,
Craig
"Craig Buchanan" <so*****@microsoft.com> schrieb Which vb.net object is the best match for the vb6 collection class? Specifically, I would like to be able to access the Item property with an index or a key string.
I wrote my own class that inherits from the collectionbase and uses an arraylist to hold values, but i'm missing the Item(string) property. I suppose I could iterate thru the collection and look for a string match, but I thought there might be an easier way.
Microsoft.VisualBasic.Collection is not a part of VB6, it's a part of VB.NET
and the Framework. You can use it. It is not part of the compatibility
library that is only there for compatibility reasons.
--
Armin
"Craig Buchanan" <so*****@microsoft.com> schrieb Which vb.net object is the best match for the vb6 collection class? Specifically, I would like to be able to access the Item property with an index or a key string.
I wrote my own class that inherits from the collectionbase and uses an arraylist to hold values, but i'm missing the Item(string) property. I suppose I could iterate thru the collection and look for a string match, but I thought there might be an easier way.
Microsoft.VisualBasic.Collection is not a part of VB6, it's a part of VB.NET
and the Framework. You can use it. It is not part of the compatibility
library that is only there for compatibility reasons.
--
Armin
Hi Armin
I don't think it is just Craig who shies away from the Microsoft.VisualBasic
namespace. Perhaps it is the Compatibility namespace that has given it a bad
name, but I also have been reluctant to use its methods.
The .NET classes and methods have a subtly different feel to them, whilst
the VisualBasic namespace retains classic VB names that make one feel that
they are in some way retro.
I have seen many posts from people who believe that these are old-style
functions that are present for compatibility reasons, and that somewhere
there must be newer, 'true' framework versions.
I am coming to the conclusion that this is not the case, but it is perhaps
odd that so many people have been labouring under the same misapprehension.
Charles
"Armin Zingler" <az*******@freenet.de> wrote in message
news:40***********************@news.freenet.de... "Craig Buchanan" <so*****@microsoft.com> schrieb Which vb.net object is the best match for the vb6 collection class? Specifically, I would like to be able to access the Item property with an index or a key string.
I wrote my own class that inherits from the collectionbase and uses an arraylist to hold values, but i'm missing the Item(string) property. I suppose I could iterate thru the collection and look for a string match, but I thought there might be an easier way. Microsoft.VisualBasic.Collection is not a part of VB6, it's a part of
VB.NET and the Framework. You can use it. It is not part of the compatibility library that is only there for compatibility reasons.
-- Armin
Hi Armin
I don't think it is just Craig who shies away from the Microsoft.VisualBasic
namespace. Perhaps it is the Compatibility namespace that has given it a bad
name, but I also have been reluctant to use its methods.
The .NET classes and methods have a subtly different feel to them, whilst
the VisualBasic namespace retains classic VB names that make one feel that
they are in some way retro.
I have seen many posts from people who believe that these are old-style
functions that are present for compatibility reasons, and that somewhere
there must be newer, 'true' framework versions.
I am coming to the conclusion that this is not the case, but it is perhaps
odd that so many people have been labouring under the same misapprehension.
Charles
"Armin Zingler" <az*******@freenet.de> wrote in message
news:40***********************@news.freenet.de... "Craig Buchanan" <so*****@microsoft.com> schrieb Which vb.net object is the best match for the vb6 collection class? Specifically, I would like to be able to access the Item property with an index or a key string.
I wrote my own class that inherits from the collectionbase and uses an arraylist to hold values, but i'm missing the Item(string) property. I suppose I could iterate thru the collection and look for a string match, but I thought there might be an easier way. Microsoft.VisualBasic.Collection is not a part of VB6, it's a part of
VB.NET and the Framework. You can use it. It is not part of the compatibility library that is only there for compatibility reasons.
-- Armin
Craig,
As the others have suggested you could continue to use
Microsoft.VisualBasic.Collection.
Alternatively you can start with CollectionBase and add a contained
HashTable, or start with DictionaryBase and add a contained ArrayList. Then
simply add two Item properties one for Integer & one for String.
A Third "better" alternative may be to start with
System.Collections.Specialized.NameObjectCollectio nBase and add two Item
properties.
There are a couple of other collections (NameValueCollection for example) in
System.Collections.Specialized that may be useful also.
I prefer to start with CollectionBase, DictionaryBase, or
NameObjectCollectionBase as they allow me to have type safe collections!
Hope this helps
Jay
"Craig Buchanan" <so*****@microsoft.com> wrote in message
news:e9*************@TK2MSFTNGP12.phx.gbl... Which vb.net object is the best match for the vb6 collection class? Specifically, I would like to be able to access the Item property with an index or a key string.
I wrote my own class that inherits from the collectionbase and uses an arraylist to hold values, but i'm missing the Item(string) property. I suppose I could iterate thru the collection and look for a string match,
but I thought there might be an easier way.
Thanks,
Craig
Craig,
As the others have suggested you could continue to use
Microsoft.VisualBasic.Collection.
Alternatively you can start with CollectionBase and add a contained
HashTable, or start with DictionaryBase and add a contained ArrayList. Then
simply add two Item properties one for Integer & one for String.
A Third "better" alternative may be to start with
System.Collections.Specialized.NameObjectCollectio nBase and add two Item
properties.
There are a couple of other collections (NameValueCollection for example) in
System.Collections.Specialized that may be useful also.
I prefer to start with CollectionBase, DictionaryBase, or
NameObjectCollectionBase as they allow me to have type safe collections!
Hope this helps
Jay
"Craig Buchanan" <so*****@microsoft.com> wrote in message
news:e9*************@TK2MSFTNGP12.phx.gbl... Which vb.net object is the best match for the vb6 collection class? Specifically, I would like to be able to access the Item property with an index or a key string.
I wrote my own class that inherits from the collectionbase and uses an arraylist to hold values, but i'm missing the Item(string) property. I suppose I could iterate thru the collection and look for a string match,
but I thought there might be an easier way.
Thanks,
Craig
Hi Craig and all others,
I am like Armin with the ones who always say that the Microsoft.Visual basic
namespace is not for compatible reasons. However, I did wish they had placed
the Microsoft.Visualbasic collection in the compatible namespace. In my
opinion, it is so very different from all what is used in dotNet that you
have to investigate time in it and always have to keep track of those
specialities it has.
As an addition to Ken, Jay and your own method, which is the way I too would
go in the start, is that I more and more use the datatable. There is so much
in that class, that using the Ilist derived classes and the Icomparer needs
a lot of time to create things, while that is done with the datatable mostly
in one or two lines.
Just my thought,
Cor
Hi Craig and all others,
I am like Armin with the ones who always say that the Microsoft.Visual basic
namespace is not for compatible reasons. However, I did wish they had placed
the Microsoft.Visualbasic collection in the compatible namespace. In my
opinion, it is so very different from all what is used in dotNet that you
have to investigate time in it and always have to keep track of those
specialities it has.
As an addition to Ken, Jay and your own method, which is the way I too would
go in the start, is that I more and more use the datatable. There is so much
in that class, that using the Ilist derived classes and the Icomparer needs
a lot of time to create things, while that is done with the datatable mostly
in one or two lines.
Just my thought,
Cor
Hi Jay
I'm not really trying to hijack this thread, but it continues to touch on
areas that currently concern me as well.
With respect to the specific question of collections, I too have been
looking for a ready-made collection that supports key and item, is sortable,
but can also be serialised using the XML serialiser. Whilst the suggestions
you make separately fulfil parts of these goals, I don't think any one of
them is the full Monty (e.g. anything using IDictionary cannot be
automatically serialised) ... but I may be wrong.
Can you suggest a solution with these aims in mind?
Thanks.
Charles
"Jay B. Harlow [MVP - Outlook]" <Ja************@msn.com> wrote in message
news:Og**************@TK2MSFTNGP09.phx.gbl... Craig, As the others have suggested you could continue to use Microsoft.VisualBasic.Collection.
Alternatively you can start with CollectionBase and add a contained HashTable, or start with DictionaryBase and add a contained ArrayList.
Then simply add two Item properties one for Integer & one for String.
A Third "better" alternative may be to start with System.Collections.Specialized.NameObjectCollectio nBase and add two Item properties.
There are a couple of other collections (NameValueCollection for example)
in System.Collections.Specialized that may be useful also.
I prefer to start with CollectionBase, DictionaryBase, or NameObjectCollectionBase as they allow me to have type safe collections!
Hope this helps Jay
"Craig Buchanan" <so*****@microsoft.com> wrote in message news:e9*************@TK2MSFTNGP12.phx.gbl... Which vb.net object is the best match for the vb6 collection class? Specifically, I would like to be able to access the Item property with
an index or a key string.
I wrote my own class that inherits from the collectionbase and uses an arraylist to hold values, but i'm missing the Item(string) property. I suppose I could iterate thru the collection and look for a string match, but I thought there might be an easier way.
Thanks,
Craig
Hi Jay
I'm not really trying to hijack this thread, but it continues to touch on
areas that currently concern me as well.
With respect to the specific question of collections, I too have been
looking for a ready-made collection that supports key and item, is sortable,
but can also be serialised using the XML serialiser. Whilst the suggestions
you make separately fulfil parts of these goals, I don't think any one of
them is the full Monty (e.g. anything using IDictionary cannot be
automatically serialised) ... but I may be wrong.
Can you suggest a solution with these aims in mind?
Thanks.
Charles
"Jay B. Harlow [MVP - Outlook]" <Ja************@msn.com> wrote in message
news:Og**************@TK2MSFTNGP09.phx.gbl... Craig, As the others have suggested you could continue to use Microsoft.VisualBasic.Collection.
Alternatively you can start with CollectionBase and add a contained HashTable, or start with DictionaryBase and add a contained ArrayList.
Then simply add two Item properties one for Integer & one for String.
A Third "better" alternative may be to start with System.Collections.Specialized.NameObjectCollectio nBase and add two Item properties.
There are a couple of other collections (NameValueCollection for example)
in System.Collections.Specialized that may be useful also.
I prefer to start with CollectionBase, DictionaryBase, or NameObjectCollectionBase as they allow me to have type safe collections!
Hope this helps Jay
"Craig Buchanan" <so*****@microsoft.com> wrote in message news:e9*************@TK2MSFTNGP12.phx.gbl... Which vb.net object is the best match for the vb6 collection class? Specifically, I would like to be able to access the Item property with
an index or a key string.
I wrote my own class that inherits from the collectionbase and uses an arraylist to hold values, but i'm missing the Item(string) property. I suppose I could iterate thru the collection and look for a string match, but I thought there might be an easier way.
Thanks,
Craig
Hi Charles,
What is against the dataset it has everything you are asking for build in in
my opinion?
Cor
Hi Charles,
What is against the dataset it has everything you are asking for build in in
my opinion?
Cor
Hi Cor
I hadn't thought of the dataset, I suppose because I tend to think of it
more as a database orientated class, but I will take a look now.
Thanks
Charles
"Cor" <no*@non.com> wrote in message
news:O9**************@TK2MSFTNGP12.phx.gbl... Hi Charles,
What is against the dataset it has everything you are asking for build in
in my opinion?
Cor
Hi Cor
I hadn't thought of the dataset, I suppose because I tend to think of it
more as a database orientated class, but I will take a look now.
Thanks
Charles
"Cor" <no*@non.com> wrote in message
news:O9**************@TK2MSFTNGP12.phx.gbl... Hi Charles,
What is against the dataset it has everything you are asking for build in
in my opinion?
Cor
Charles,
Unfortunately I do not do a lot of XML serialization, so I currently do not
have an answer for you, other then what I stated in the other thread.
Also are you referring to the XML serializer or the SOAP serializer? They
are different: one is used the same as BinarySerilazer, while the other is
used for Web Services, my understanding is that the SOAP serializer is more
limited as SOAP is more limited. HOwever I have not done a lot with either
SOAP or XML serialization.
Hope this helps
Jay
"Charles Law" <bl***@nowhere.com> wrote in message
news:uP**************@TK2MSFTNGP09.phx.gbl... Hi Jay
I'm not really trying to hijack this thread, but it continues to touch on areas that currently concern me as well.
With respect to the specific question of collections, I too have been looking for a ready-made collection that supports key and item, is
sortable, but can also be serialised using the XML serialiser. Whilst the
suggestions you make separately fulfil parts of these goals, I don't think any one of them is the full Monty (e.g. anything using IDictionary cannot be automatically serialised) ... but I may be wrong.
Can you suggest a solution with these aims in mind?
Thanks.
Charles
"Jay B. Harlow [MVP - Outlook]" <Ja************@msn.com> wrote in message news:Og**************@TK2MSFTNGP09.phx.gbl... Craig, As the others have suggested you could continue to use Microsoft.VisualBasic.Collection.
Alternatively you can start with CollectionBase and add a contained HashTable, or start with DictionaryBase and add a contained ArrayList. Then simply add two Item properties one for Integer & one for String.
A Third "better" alternative may be to start with System.Collections.Specialized.NameObjectCollectio nBase and add two Item properties.
There are a couple of other collections (NameValueCollection for
example) in System.Collections.Specialized that may be useful also.
I prefer to start with CollectionBase, DictionaryBase, or NameObjectCollectionBase as they allow me to have type safe collections!
Hope this helps Jay
"Craig Buchanan" <so*****@microsoft.com> wrote in message news:e9*************@TK2MSFTNGP12.phx.gbl... Which vb.net object is the best match for the vb6 collection class? Specifically, I would like to be able to access the Item property with an index or a key string.
I wrote my own class that inherits from the collectionbase and uses an arraylist to hold values, but i'm missing the Item(string) property.
I suppose I could iterate thru the collection and look for a string
match, but I thought there might be an easier way.
Thanks,
Craig
Charles,
Unfortunately I do not do a lot of XML serialization, so I currently do not
have an answer for you, other then what I stated in the other thread.
Also are you referring to the XML serializer or the SOAP serializer? They
are different: one is used the same as BinarySerilazer, while the other is
used for Web Services, my understanding is that the SOAP serializer is more
limited as SOAP is more limited. HOwever I have not done a lot with either
SOAP or XML serialization.
Hope this helps
Jay
"Charles Law" <bl***@nowhere.com> wrote in message
news:uP**************@TK2MSFTNGP09.phx.gbl... Hi Jay
I'm not really trying to hijack this thread, but it continues to touch on areas that currently concern me as well.
With respect to the specific question of collections, I too have been looking for a ready-made collection that supports key and item, is
sortable, but can also be serialised using the XML serialiser. Whilst the
suggestions you make separately fulfil parts of these goals, I don't think any one of them is the full Monty (e.g. anything using IDictionary cannot be automatically serialised) ... but I may be wrong.
Can you suggest a solution with these aims in mind?
Thanks.
Charles
"Jay B. Harlow [MVP - Outlook]" <Ja************@msn.com> wrote in message news:Og**************@TK2MSFTNGP09.phx.gbl... Craig, As the others have suggested you could continue to use Microsoft.VisualBasic.Collection.
Alternatively you can start with CollectionBase and add a contained HashTable, or start with DictionaryBase and add a contained ArrayList. Then simply add two Item properties one for Integer & one for String.
A Third "better" alternative may be to start with System.Collections.Specialized.NameObjectCollectio nBase and add two Item properties.
There are a couple of other collections (NameValueCollection for
example) in System.Collections.Specialized that may be useful also.
I prefer to start with CollectionBase, DictionaryBase, or NameObjectCollectionBase as they allow me to have type safe collections!
Hope this helps Jay
"Craig Buchanan" <so*****@microsoft.com> wrote in message news:e9*************@TK2MSFTNGP12.phx.gbl... Which vb.net object is the best match for the vb6 collection class? Specifically, I would like to be able to access the Item property with an index or a key string.
I wrote my own class that inherits from the collectionbase and uses an arraylist to hold values, but i'm missing the Item(string) property.
I suppose I could iterate thru the collection and look for a string
match, but I thought there might be an easier way.
Thanks,
Craig
Cor,
A Dataset is used to contain a set or Data Rows.
A Collection is used to contain a set of objects.
Being an Object Oriented programmer, I find containing a set of objects is
much more powerful then containing a set of Data rows.
Unfortunately I do not have a good resource on when you should choose a Data
Centric (DataSet) approach or an Object Oriented approach. Although I find
keeping both options available is far better then saying. We are only using
one or the other!
Hope this helps
Jay
"Cor" <no*@non.com> wrote in message
news:O9**************@TK2MSFTNGP12.phx.gbl... Hi Charles,
What is against the dataset it has everything you are asking for build in
in my opinion?
Cor
Cor,
A Dataset is used to contain a set or Data Rows.
A Collection is used to contain a set of objects.
Being an Object Oriented programmer, I find containing a set of objects is
much more powerful then containing a set of Data rows.
Unfortunately I do not have a good resource on when you should choose a Data
Centric (DataSet) approach or an Object Oriented approach. Although I find
keeping both options available is far better then saying. We are only using
one or the other!
Hope this helps
Jay
"Cor" <no*@non.com> wrote in message
news:O9**************@TK2MSFTNGP12.phx.gbl... Hi Charles,
What is against the dataset it has everything you are asking for build in
in my opinion?
Cor
Hi Jay B,
Did you see me giving an answer on Charles last question about the XML
serializer, that is because I agree this with you (I am sad you even do
think I am not).
:-)
However in this thread he was asking about a collection and in my simple
mind it was a collection of data.
So I pointed Charles on the dataset, because that is a very easy collection
when it is all about data.
And I was in doubt if I would look for Charles for the XML serializer
because I did give someone an answer yesterday where that was in. However I
decided to do that this time not. I do not know of the complexebility of the
object Charles wants to serialize (which is mostly simple) and deserialize
(which is mostly difficult) . And because Charles always start telling the
question simple and than comes an "however I am using it in that way", I did
it this time not, but decided to wait for that last one.
:-)
Cor
Hi Jay B,
Did you see me giving an answer on Charles last question about the XML
serializer, that is because I agree this with you (I am sad you even do
think I am not).
:-)
However in this thread he was asking about a collection and in my simple
mind it was a collection of data.
So I pointed Charles on the dataset, because that is a very easy collection
when it is all about data.
And I was in doubt if I would look for Charles for the XML serializer
because I did give someone an answer yesterday where that was in. However I
decided to do that this time not. I do not know of the complexebility of the
object Charles wants to serialize (which is mostly simple) and deserialize
(which is mostly difficult) . And because Charles always start telling the
question simple and than comes an "however I am using it in that way", I did
it this time not, but decided to wait for that last one.
:-)
Cor
Hi Cor
You have found me out ;-) I do tend to keep my questions simple to start
with because I don't want to put people off having a go at answering. I also
cut out all the stuff that I don't think is relevant, and which might set
people thinking of an inappropriate solution.
The serialiser question is a good example. With each post I have added some
extra detail. I generally like to find things out for myself, because I
think I will learn and remember better that way, so I also don't seek for
people to give me the full answer but just a nudge in the right direction.
In this case, though, I have seen many posts on this subject which allude to
the same thing, that there is no direct replacement for the
VisualBasic.Collection. That is a shame, because many people find that it
has exactly what they want from a collection.
As for serialising, I get the impression that not being able to serialise a
class that implements IDictionary (without hand-coding) is a short-coming,
and therefore may be added later by Microsoft. I hope so anyway.
Regards
Charles
"Cor Ligthert" <no**********@planet.nl> wrote in message
news:e6**************@TK2MSFTNGP09.phx.gbl... Hi Jay B,
Did you see me giving an answer on Charles last question about the XML serializer, that is because I agree this with you (I am sad you even do think I am not).
:-)
However in this thread he was asking about a collection and in my simple mind it was a collection of data.
So I pointed Charles on the dataset, because that is a very easy
collection when it is all about data.
And I was in doubt if I would look for Charles for the XML serializer because I did give someone an answer yesterday where that was in. However
I decided to do that this time not. I do not know of the complexebility of
the object Charles wants to serialize (which is mostly simple) and deserialize (which is mostly difficult) . And because Charles always start telling the question simple and than comes an "however I am using it in that way", I
did it this time not, but decided to wait for that last one.
:-)
Cor
Hi Cor
You have found me out ;-) I do tend to keep my questions simple to start
with because I don't want to put people off having a go at answering. I also
cut out all the stuff that I don't think is relevant, and which might set
people thinking of an inappropriate solution.
The serialiser question is a good example. With each post I have added some
extra detail. I generally like to find things out for myself, because I
think I will learn and remember better that way, so I also don't seek for
people to give me the full answer but just a nudge in the right direction.
In this case, though, I have seen many posts on this subject which allude to
the same thing, that there is no direct replacement for the
VisualBasic.Collection. That is a shame, because many people find that it
has exactly what they want from a collection.
As for serialising, I get the impression that not being able to serialise a
class that implements IDictionary (without hand-coding) is a short-coming,
and therefore may be added later by Microsoft. I hope so anyway.
Regards
Charles
"Cor Ligthert" <no**********@planet.nl> wrote in message
news:e6**************@TK2MSFTNGP09.phx.gbl... Hi Jay B,
Did you see me giving an answer on Charles last question about the XML serializer, that is because I agree this with you (I am sad you even do think I am not).
:-)
However in this thread he was asking about a collection and in my simple mind it was a collection of data.
So I pointed Charles on the dataset, because that is a very easy
collection when it is all about data.
And I was in doubt if I would look for Charles for the XML serializer because I did give someone an answer yesterday where that was in. However
I decided to do that this time not. I do not know of the complexebility of
the object Charles wants to serialize (which is mostly simple) and deserialize (which is mostly difficult) . And because Charles always start telling the question simple and than comes an "however I am using it in that way", I
did it this time not, but decided to wait for that last one.
:-)
Cor
Cor,
I was neither agreeing nor disagreeing with you! At the same time I was both
Agreeing & Disagreeing with you! ;-)
You made a statement, in the form of a question: What is against the dataset it has everything you are asking for build in in my opinion?
I was answering the question, The fact a dataset can only hold data rows is
something significant against it.
If you are a Data centric programmer then yes, using a DataSet is fine. So
in this regard I was agreeing with you.
However I find significantly more value in being an Object Oriented
programmer, so a lot of times a DataSet is too limiting. So in this regard I
was disagreeing with you.
Remember Object Oriented thinking involves organizing your app by
responsibility & behaviors, not simply I have a collection of data...
As I stated, using a Data centric approach is appropriate sometimes and
using an Object Oriented approach is appropriate .
Hope this helps
Jay
"Cor Ligthert" <no**********@planet.nl> wrote in message
news:e6**************@TK2MSFTNGP09.phx.gbl... Hi Jay B,
Did you see me giving an answer on Charles last question about the XML serializer, that is because I agree this with you (I am sad you even do think I am not).
:-)
However in this thread he was asking about a collection and in my simple mind it was a collection of data.
So I pointed Charles on the dataset, because that is a very easy
collection when it is all about data.
And I was in doubt if I would look for Charles for the XML serializer because I did give someone an answer yesterday where that was in. However
I decided to do that this time not. I do not know of the complexebility of
the object Charles wants to serialize (which is mostly simple) and deserialize (which is mostly difficult) . And because Charles always start telling the question simple and than comes an "however I am using it in that way", I
did it this time not, but decided to wait for that last one.
:-)
Cor
Cor,
I was neither agreeing nor disagreeing with you! At the same time I was both
Agreeing & Disagreeing with you! ;-)
You made a statement, in the form of a question: What is against the dataset it has everything you are asking for build in in my opinion?
I was answering the question, The fact a dataset can only hold data rows is
something significant against it.
If you are a Data centric programmer then yes, using a DataSet is fine. So
in this regard I was agreeing with you.
However I find significantly more value in being an Object Oriented
programmer, so a lot of times a DataSet is too limiting. So in this regard I
was disagreeing with you.
Remember Object Oriented thinking involves organizing your app by
responsibility & behaviors, not simply I have a collection of data...
As I stated, using a Data centric approach is appropriate sometimes and
using an Object Oriented approach is appropriate .
Hope this helps
Jay
"Cor Ligthert" <no**********@planet.nl> wrote in message
news:e6**************@TK2MSFTNGP09.phx.gbl... Hi Jay B,
Did you see me giving an answer on Charles last question about the XML serializer, that is because I agree this with you (I am sad you even do think I am not).
:-)
However in this thread he was asking about a collection and in my simple mind it was a collection of data.
So I pointed Charles on the dataset, because that is a very easy
collection when it is all about data.
And I was in doubt if I would look for Charles for the XML serializer because I did give someone an answer yesterday where that was in. However
I decided to do that this time not. I do not know of the complexebility of
the object Charles wants to serialize (which is mostly simple) and deserialize (which is mostly difficult) . And because Charles always start telling the question simple and than comes an "however I am using it in that way", I
did it this time not, but decided to wait for that last one.
:-)
Cor
Hi Jay and Charles,
Thanks however, I did also thinking this over, two points do not forget the
extensibility of a dataset is limited by the very basic concepts of SQL.
(Jay you maybe know that I hate that "scripting" SQL language what you in my
opinion should do too because there is nothing less OOP than that in my
opinion) .
Another point I have thought on is that it is easy to put a serialized
string in a datarow. So my chalenge for the weekend is to fullfill the
question from Charles (I have seen samples so I hope it should go) and than
put them in a datarow, what is of course a piece of cake.
Hi Charles if this beneath is not what you mean, do than tell it to me?
--------------
XML serialization serializes only the public fields and property values of
an object into an XML stream. XML serialization does not include type
information. For example, if you have a Book object that exists in the
Library namespace, there is no guarantee that it will be deserialized into
an object of the same type.
---------------
I hope that I can do it with this and do not need the memstream because than
it is already ready.
\\\
Dim x As XmlSerializer = new XmlSerializer(GetType(MyClass))
Dim sw As New System.IO.StringWriter
x.Serialize(sw, MyObject)
ds.tables(0).rows(0)(0) = sw.tostring
///
I did not do this serialization of an object before so I am not sure I
succeed.
And Charles when it is with this hint ready for tomorrow European Time, do
not forget to tell it to me.
:-))
Cor
Hi Jay and Charles,
Thanks however, I did also thinking this over, two points do not forget the
extensibility of a dataset is limited by the very basic concepts of SQL.
(Jay you maybe know that I hate that "scripting" SQL language what you in my
opinion should do too because there is nothing less OOP than that in my
opinion) .
Another point I have thought on is that it is easy to put a serialized
string in a datarow. So my chalenge for the weekend is to fullfill the
question from Charles (I have seen samples so I hope it should go) and than
put them in a datarow, what is of course a piece of cake.
Hi Charles if this beneath is not what you mean, do than tell it to me?
--------------
XML serialization serializes only the public fields and property values of
an object into an XML stream. XML serialization does not include type
information. For example, if you have a Book object that exists in the
Library namespace, there is no guarantee that it will be deserialized into
an object of the same type.
---------------
I hope that I can do it with this and do not need the memstream because than
it is already ready.
\\\
Dim x As XmlSerializer = new XmlSerializer(GetType(MyClass))
Dim sw As New System.IO.StringWriter
x.Serialize(sw, MyObject)
ds.tables(0).rows(0)(0) = sw.tostring
///
I did not do this serialization of an object before so I am not sure I
succeed.
And Charles when it is with this hint ready for tomorrow European Time, do
not forget to tell it to me.
:-))
Cor
Hi Charles,
It was not that difficult.
It is a complete sample and I have placed also the dataset, and a combobox
to test.
The persons are from for us Benelux people from one of the famous Belgian
cartonists Vandersteen, that is because EricJ has often in his samples
Itemke, what is a kind of Dutch the Belgians always do and from which
Dutchman know it are Belgians.
I hope this helps you?
Cor
\\\
Private WithEvents combobox1 As New ComboBox
Private strt As Boolean
Private Sub Form1_Load(ByVal sender As Object, _
ByVal e As System.EventArgs) Handles MyBase.Load
Dim Belgen As New BelgenCollection
Belgen.Add(New Belg(New String() {"Lambiek", "Man", "Jenever"}))
Belgen.Add(New Belg(New String() {"Sidonia", "Vrouw", "Likeur"}))
Belgen.Add(New Belg(New String() {"Suske", "Jongen", "Cola"}))
Belgen.Add(New Belg(New String() {"Wiske", "Meisje", "Limonade"}))
Belgen.Add(New Belg(New String() {"Jerom", "Jongeman", "Bier"}))
Dim Serializer As New
Xml.Serialization.XmlSerializer(GetType(BelgenColl ection))
Dim sw As New System.IO.StringWriter
Serializer.Serialize(sw, Belgen)
Dim ds As New DataSet
Dim dt As New DataTable("Jay")
Dim dc As New DataColumn("Charles")
'This part only for Jay and Charles if he wants
dt.Columns.Add(dc)
ds.Tables.Add(dt)
dt.Rows.Add(dt.NewRow)
ds.Tables(0).Rows(0)(0) = sw.ToString
ds.WriteXml("c:\test1\charles.xml")
Dim dsJay As New DataSet
dsJay.ReadXml("c:\test1\Charles.xml")
Dim Charles As String = dsJay.Tables(0).Rows(0)(0).ToString
'End Jay part
Dim Deserializer As New Xml.Serialization.XmlSerializer _
(GetType(BelgenCollection))
Dim sr As New System.IO.StringReader(Charles)
Dim reader As New System.Xml.XmlTextReader(sr)
Dim Vlamingen As BelgenCollection
Vlamingen = CType(Deserializer.Deserialize(reader), _
BelgenCollection)
Me.Controls.Add(combobox1)
combobox1.DataSource = Vlamingen
strt = True
End Sub
Private Sub combobox1_SelectedIndexChanged(ByVal _
sender As Object, ByVal e As System.EventArgs) _
Handles combobox1.SelectedIndexChanged
If strt = True Then
MessageBox.Show(DirectCast(combobox1.SelectedValue , Belg).drank)
End If
End Sub
End Class
///
\\\
Public Class Belg
Public Naam As String
Public sex As String
Public drank As String
Public Sub New()
End Sub
Public Sub New(ByVal fill As String())
Naam = fill(0)
sex = fill(1)
drank = fill(2)
End Sub
Public Overrides Function tostring() As String
Return Naam
End Function
End Class
Public Class BelgenCollection
Inherits System.Collections.CollectionBase
Default Public Overloads ReadOnly _
Property Item(ByVal index As Integer) As Belg
Get
Return DirectCast(list.Item(index), Belg)
End Get
End Property
Public Sub Add(ByVal aBelg As Belg)
List.Add(aBelg)
End Sub
End Class
Hi Charles,
It was not that difficult.
It is a complete sample and I have placed also the dataset, and a combobox
to test.
The persons are from for us Benelux people from one of the famous Belgian
cartonists Vandersteen, that is because EricJ has often in his samples
Itemke, what is a kind of Dutch the Belgians always do and from which
Dutchman know it are Belgians.
I hope this helps you?
Cor
\\\
Private WithEvents combobox1 As New ComboBox
Private strt As Boolean
Private Sub Form1_Load(ByVal sender As Object, _
ByVal e As System.EventArgs) Handles MyBase.Load
Dim Belgen As New BelgenCollection
Belgen.Add(New Belg(New String() {"Lambiek", "Man", "Jenever"}))
Belgen.Add(New Belg(New String() {"Sidonia", "Vrouw", "Likeur"}))
Belgen.Add(New Belg(New String() {"Suske", "Jongen", "Cola"}))
Belgen.Add(New Belg(New String() {"Wiske", "Meisje", "Limonade"}))
Belgen.Add(New Belg(New String() {"Jerom", "Jongeman", "Bier"}))
Dim Serializer As New
Xml.Serialization.XmlSerializer(GetType(BelgenColl ection))
Dim sw As New System.IO.StringWriter
Serializer.Serialize(sw, Belgen)
Dim ds As New DataSet
Dim dt As New DataTable("Jay")
Dim dc As New DataColumn("Charles")
'This part only for Jay and Charles if he wants
dt.Columns.Add(dc)
ds.Tables.Add(dt)
dt.Rows.Add(dt.NewRow)
ds.Tables(0).Rows(0)(0) = sw.ToString
ds.WriteXml("c:\test1\charles.xml")
Dim dsJay As New DataSet
dsJay.ReadXml("c:\test1\Charles.xml")
Dim Charles As String = dsJay.Tables(0).Rows(0)(0).ToString
'End Jay part
Dim Deserializer As New Xml.Serialization.XmlSerializer _
(GetType(BelgenCollection))
Dim sr As New System.IO.StringReader(Charles)
Dim reader As New System.Xml.XmlTextReader(sr)
Dim Vlamingen As BelgenCollection
Vlamingen = CType(Deserializer.Deserialize(reader), _
BelgenCollection)
Me.Controls.Add(combobox1)
combobox1.DataSource = Vlamingen
strt = True
End Sub
Private Sub combobox1_SelectedIndexChanged(ByVal _
sender As Object, ByVal e As System.EventArgs) _
Handles combobox1.SelectedIndexChanged
If strt = True Then
MessageBox.Show(DirectCast(combobox1.SelectedValue , Belg).drank)
End If
End Sub
End Class
///
\\\
Public Class Belg
Public Naam As String
Public sex As String
Public drank As String
Public Sub New()
End Sub
Public Sub New(ByVal fill As String())
Naam = fill(0)
sex = fill(1)
drank = fill(2)
End Sub
Public Overrides Function tostring() As String
Return Naam
End Function
End Class
Public Class BelgenCollection
Inherits System.Collections.CollectionBase
Default Public Overloads ReadOnly _
Property Item(ByVal index As Integer) As Belg
Get
Return DirectCast(list.Item(index), Belg)
End Get
End Property
Public Sub Add(ByVal aBelg As Belg)
List.Add(aBelg)
End Sub
End Class
Hi Jay,
Succeeded completly I thought have a look at Charles
Cor
Hi Jay,
Succeeded completly I thought have a look at Charles
Cor
Hi Cor
That looks great. I will have to try it later as I am supposed to be going
to Longleat any moment now, and then we have guests until Monday. But
thanks, and I will get back to you.
Charles
"Cor Ligthert" <no**********@planet.nl> wrote in message
news:Oj**************@TK2MSFTNGP09.phx.gbl... Hi Charles,
It was not that difficult.
It is a complete sample and I have placed also the dataset, and a combobox to test.
The persons are from for us Benelux people from one of the famous Belgian cartonists Vandersteen, that is because EricJ has often in his samples Itemke, what is a kind of Dutch the Belgians always do and from which Dutchman know it are Belgians.
I hope this helps you?
Cor
\\\ Private WithEvents combobox1 As New ComboBox Private strt As Boolean Private Sub Form1_Load(ByVal sender As Object, _ ByVal e As System.EventArgs) Handles MyBase.Load Dim Belgen As New BelgenCollection Belgen.Add(New Belg(New String() {"Lambiek", "Man", "Jenever"})) Belgen.Add(New Belg(New String() {"Sidonia", "Vrouw", "Likeur"})) Belgen.Add(New Belg(New String() {"Suske", "Jongen", "Cola"})) Belgen.Add(New Belg(New String() {"Wiske", "Meisje", "Limonade"})) Belgen.Add(New Belg(New String() {"Jerom", "Jongeman", "Bier"})) Dim Serializer As New Xml.Serialization.XmlSerializer(GetType(BelgenColl ection)) Dim sw As New System.IO.StringWriter Serializer.Serialize(sw, Belgen) Dim ds As New DataSet Dim dt As New DataTable("Jay") Dim dc As New DataColumn("Charles") 'This part only for Jay and Charles if he wants dt.Columns.Add(dc) ds.Tables.Add(dt) dt.Rows.Add(dt.NewRow) ds.Tables(0).Rows(0)(0) = sw.ToString ds.WriteXml("c:\test1\charles.xml") Dim dsJay As New DataSet dsJay.ReadXml("c:\test1\Charles.xml") Dim Charles As String = dsJay.Tables(0).Rows(0)(0).ToString 'End Jay part Dim Deserializer As New Xml.Serialization.XmlSerializer _ (GetType(BelgenCollection)) Dim sr As New System.IO.StringReader(Charles) Dim reader As New System.Xml.XmlTextReader(sr) Dim Vlamingen As BelgenCollection Vlamingen = CType(Deserializer.Deserialize(reader), _ BelgenCollection) Me.Controls.Add(combobox1) combobox1.DataSource = Vlamingen strt = True End Sub Private Sub combobox1_SelectedIndexChanged(ByVal _ sender As Object, ByVal e As System.EventArgs) _ Handles combobox1.SelectedIndexChanged If strt = True Then MessageBox.Show(DirectCast(combobox1.SelectedValue ,
Belg).drank) End If End Sub End Class /// \\\ Public Class Belg Public Naam As String Public sex As String Public drank As String Public Sub New() End Sub Public Sub New(ByVal fill As String()) Naam = fill(0) sex = fill(1) drank = fill(2) End Sub Public Overrides Function tostring() As String Return Naam End Function End Class Public Class BelgenCollection Inherits System.Collections.CollectionBase Default Public Overloads ReadOnly _ Property Item(ByVal index As Integer) As Belg Get Return DirectCast(list.Item(index), Belg) End Get End Property Public Sub Add(ByVal aBelg As Belg) List.Add(aBelg) End Sub End Class
Hi Cor
That looks great. I will have to try it later as I am supposed to be going
to Longleat any moment now, and then we have guests until Monday. But
thanks, and I will get back to you.
Charles
"Cor Ligthert" <no**********@planet.nl> wrote in message
news:Oj**************@TK2MSFTNGP09.phx.gbl... Hi Charles,
It was not that difficult.
It is a complete sample and I have placed also the dataset, and a combobox to test.
The persons are from for us Benelux people from one of the famous Belgian cartonists Vandersteen, that is because EricJ has often in his samples Itemke, what is a kind of Dutch the Belgians always do and from which Dutchman know it are Belgians.
I hope this helps you?
Cor
\\\ Private WithEvents combobox1 As New ComboBox Private strt As Boolean Private Sub Form1_Load(ByVal sender As Object, _ ByVal e As System.EventArgs) Handles MyBase.Load Dim Belgen As New BelgenCollection Belgen.Add(New Belg(New String() {"Lambiek", "Man", "Jenever"})) Belgen.Add(New Belg(New String() {"Sidonia", "Vrouw", "Likeur"})) Belgen.Add(New Belg(New String() {"Suske", "Jongen", "Cola"})) Belgen.Add(New Belg(New String() {"Wiske", "Meisje", "Limonade"})) Belgen.Add(New Belg(New String() {"Jerom", "Jongeman", "Bier"})) Dim Serializer As New Xml.Serialization.XmlSerializer(GetType(BelgenColl ection)) Dim sw As New System.IO.StringWriter Serializer.Serialize(sw, Belgen) Dim ds As New DataSet Dim dt As New DataTable("Jay") Dim dc As New DataColumn("Charles") 'This part only for Jay and Charles if he wants dt.Columns.Add(dc) ds.Tables.Add(dt) dt.Rows.Add(dt.NewRow) ds.Tables(0).Rows(0)(0) = sw.ToString ds.WriteXml("c:\test1\charles.xml") Dim dsJay As New DataSet dsJay.ReadXml("c:\test1\Charles.xml") Dim Charles As String = dsJay.Tables(0).Rows(0)(0).ToString 'End Jay part Dim Deserializer As New Xml.Serialization.XmlSerializer _ (GetType(BelgenCollection)) Dim sr As New System.IO.StringReader(Charles) Dim reader As New System.Xml.XmlTextReader(sr) Dim Vlamingen As BelgenCollection Vlamingen = CType(Deserializer.Deserialize(reader), _ BelgenCollection) Me.Controls.Add(combobox1) combobox1.DataSource = Vlamingen strt = True End Sub Private Sub combobox1_SelectedIndexChanged(ByVal _ sender As Object, ByVal e As System.EventArgs) _ Handles combobox1.SelectedIndexChanged If strt = True Then MessageBox.Show(DirectCast(combobox1.SelectedValue ,
Belg).drank) End If End Sub End Class /// \\\ Public Class Belg Public Naam As String Public sex As String Public drank As String Public Sub New() End Sub Public Sub New(ByVal fill As String()) Naam = fill(0) sex = fill(1) drank = fill(2) End Sub Public Overrides Function tostring() As String Return Naam End Function End Class Public Class BelgenCollection Inherits System.Collections.CollectionBase Default Public Overloads ReadOnly _ Property Item(ByVal index As Integer) As Belg Get Return DirectCast(list.Item(index), Belg) End Get End Property Public Sub Add(ByVal aBelg As Belg) List.Add(aBelg) End Sub End Class
This discussion thread is closed Replies have been disabled for this discussion. Similar topics
15 posts
views
Thread by Phill. W |
last post: by
|
27 posts
views
Thread by Craig Buchanan |
last post: by
|
9 posts
views
Thread by Alexander Baranovsky |
last post: by
|
6 posts
views
Thread by =?Utf-8?B?R3JlZw==?= |
last post: by
| | | | | | | | | | |