Home All Groups Group Topic Archive Search About

They do this in C# can't we do it in VB??

Author
15 Jan 2006 11:31 PM
**Developer**
They do this in C# can't we do it in VB??

Public Structure DevicePropMap

Public Shared id() As Integer = {2, 3, 4, 5, 6, 7, 8, 9, 10, 11, 12, 13, 14,
15, 1026, 1027, 1028}


End Structure 'DevicePropMap

Author
15 Jan 2006 11:50 PM
Homer J Simpson
" **Developer**" <REMOVEdevelo***@a-znet.com> wrote in message
news:OVauVviGGHA.3700@TK2MSFTNGP15.phx.gbl...

> They do this in C# can't we do it in VB??
>
> Public Structure DevicePropMap
>
> Public Shared id() As Integer = {2, 3, 4, 5, 6, 7, 8, 9, 10, 11, 12, 13,
> 14, 15, 1026, 1027, 1028}
>
> End Structure 'DevicePropMap

Store 2, 3, 4, 5, 6, 7, 8, 9, 10, 11, 12, 13, 14, 15, 1026, 1027, 1028 as a
string and parse/tokenize it?
Author
16 Jan 2006 12:03 AM
Herfried K. Wagner [MVP]
" **Developer**" <REMOVEdevelo***@a-znet.com> schrieb:
> They do this in C# can't we do it in VB??
>
> Public Structure DevicePropMap
>
> Public Shared id() As Integer = {2, 3, 4, 5, 6, 7, 8, 9, 10, 11, 12, 13,
> 14, 15, 1026, 1027, 1028}
>
>
> End Structure 'DevicePropMap

Mhm...  The code semantically doesn't make sense.

--
M S   Herfried K. Wagner
M V P  <URL:http://dotnet.mvps.org/>
V B   <URL:http://classicvb.org/petition/>
Author
16 Jan 2006 12:08 AM
Armin Zingler
Show quote Hide quote
"Herfried K. Wagner [MVP]" <hirf-spam-me-here@gmx.at> schrieb
> " **Developer**" <REMOVEdevelo***@a-znet.com> schrieb:
> > They do this in C# can't we do it in VB??
> >
> > Public Structure DevicePropMap
> >
> > Public Shared id() As Integer = {2, 3, 4, 5, 6, 7, 8, 9, 10, 11,
> > 12, 13, 14, 15, 1026, 1027, 1028}
> >
> >
> > End Structure 'DevicePropMap
>
> Mhm...  The code semantically doesn't make sense.


It works with classes, why not with structures? It's just a member of the
type.


Armin
Author
16 Jan 2006 6:25 PM
Herfried K. Wagner [MVP]
Show quote Hide quote
"Armin Zingler" <az.nospam@freenet.de> schrieb:
>> > They do this in C# can't we do it in VB??
>> >
>> > Public Structure DevicePropMap
>> >
>> > Public Shared id() As Integer = {2, 3, 4, 5, 6, 7, 8, 9, 10, 11,
>> > 12, 13, 14, 15, 1026, 1027, 1028}
>> >
>> >
>> > End Structure 'DevicePropMap
>>
>> Mhm...  The code semantically doesn't make sense.
>
> It works with classes, why not with structures? It's just a member of the
> type.

Could you describe a scenario where the code above would semantically make
sense?

--
M S   Herfried K. Wagner
M V P  <URL:http://dotnet.mvps.org/>
V B   <URL:http://classicvb.org/petition/>
Author
16 Jan 2006 9:36 PM
Armin Zingler
Show quote Hide quote
"Herfried K. Wagner [MVP]" <hirf-spam-me-here@gmx.at> schrieb
> "Armin Zingler" <az.nospam@freenet.de> schrieb:
> > > > They do this in C# can't we do it in VB??
> > > >
> > > > Public Structure DevicePropMap
> > > >
> > > > Public Shared id() As Integer = {2, 3, 4, 5, 6, 7, 8, 9, 10,
> > > > 11, 12, 13, 14, 15, 1026, 1027, 1028}
> > > >
> > > >
> > > > End Structure 'DevicePropMap
> > >
> > > Mhm...  The code semantically doesn't make sense.
> >
> > It works with classes, why not with structures? It's just a member
> > of the type.
>
> Could you describe a scenario where the code above would
> semantically make sense?


This is not the answer to my question. ;-) At the same places where it makes
sense with classes.


Armin
Author
16 Jan 2006 10:25 PM
Homer J Simpson
"Armin Zingler" <az.nospam@freenet.de> wrote in message
news:eXPwWVuGGHA.1032@TK2MSFTNGP12.phx.gbl...

>> > > > Public Shared id() As Integer = {2, 3, 4, 5, 6, 7, 8, 9, 10,
>> > > > 11, 12, 13, 14, 15, 1026, 1027, 1028}

> This is not the answer to my question. ;-) At the same places where it
> makes sense with classes.

In the dark days, you could do this

10 DIM I(17)
20 FOR I = 1 TO 17
30 READ I(I)
40 NEXT I
10000 DATA 2, 3, 4, 5, 6, 7, 8, 9, 10, 11, 12, 13, 14, 15, 1026, 1027, 1028

.... but not these days!
Author
16 Jan 2006 10:49 PM
Armin Zingler
"Homer J Simpson" <nob***@nowhere.com> schrieb
> In the dark days, you could do this
>
> 10 DIM I(17)
> 20 FOR I = 1 TO 17
> 30 READ I(I)
> 40 NEXT I
> 10000 DATA 2, 3, 4, 5, 6, 7, 8, 9, 10, 11, 12, 13, 14, 15, 1026,
> 1027, 1028
>
> ... but not these days!


Still possible on my CPC emulator. ;-)


Armin
Author
16 Jan 2006 12:12 AM
Ken Tucker [MVP]
Hi,

        Use a class instead of a structure

   Public Class DevicePropMap

        Public Shared id() As Integer = {2, 3, 4, 5, 6, 7, 8, 9, 10, 11, 12,
13, 14, 15, 1026, 1027, 1028}


    End Class 'DevicePropMap


Ken
--------------
Show quoteHide quote
" **Developer**" <REMOVEdevelo***@a-znet.com> wrote in message
news:OVauVviGGHA.3700@TK2MSFTNGP15.phx.gbl...
> They do this in C# can't we do it in VB??
>
> Public Structure DevicePropMap
>
> Public Shared id() As Integer = {2, 3, 4, 5, 6, 7, 8, 9, 10, 11, 12, 13,
> 14, 15, 1026, 1027, 1028}
>
>
> End Structure 'DevicePropMap
>
>
Author
16 Jan 2006 9:08 AM
Patrice
Which version ? AFAIK it should work in 2.0...

--
Patrice

Show quoteHide quote
" **Developer**" <REMOVEdevelo***@a-znet.com> a écrit dans le message de
news:OVauVviGGHA.3700@TK2MSFTNGP15.phx.gbl...
> They do this in C# can't we do it in VB??
>
> Public Structure DevicePropMap
>
> Public Shared id() As Integer = {2, 3, 4, 5, 6, 7, 8, 9, 10, 11, 12, 13,
14,
> 15, 1026, 1027, 1028}
>
>
> End Structure 'DevicePropMap
>
>
Author
16 Jan 2006 12:08 PM
Herfried K. Wagner [MVP]
"Patrice" <nob***@nowhere.com> schrieb:
> Which version ? AFAIK it should work in 2.0...

No, it doesn't work.

BTW:  I would fire a programmer who designs a structure without instance
members...

--
M S   Herfried K. Wagner
M V P  <URL:http://dotnet.mvps.org/>
V B   <URL:http://classicvb.org/petition/>
Author
16 Jan 2006 1:46 PM
Armin Zingler
"Herfried K. Wagner [MVP]" <hirf-spam-me-here@gmx.at> schrieb
> "Patrice" <nob***@nowhere.com> schrieb:
> > Which version ? AFAIK it should work in 2.0...
>
> No, it doesn't work.
>
> BTW:  I would fire a programmer who designs a structure without
> instance members...


:-)  I guess, ***Developer*** posted only the interesting part of the
structure.


Armin
Author
16 Jan 2006 2:19 PM
**Developer**
This is the result of converting a C# program using the converter that I got
from MS.

Actually the structure did have another part but it was basically the same
except that the type was string.

I'm beyond worrying about getting fired, but just in case, what the problem
that Herfried sees?

Thanks for the replies. I'll try using Class as that was the only suggestion
as how to make it work. Wish me luck.



Thanks


Show quoteHide quote
"Armin Zingler" <az.nospam@freenet.de> wrote in message
news:eiQn8OqGGHA.4036@TK2MSFTNGP12.phx.gbl...
> "Herfried K. Wagner [MVP]" <hirf-spam-me-here@gmx.at> schrieb
>> "Patrice" <nob***@nowhere.com> schrieb:
>> > Which version ? AFAIK it should work in 2.0...
>>
>> No, it doesn't work.
>>
>> BTW:  I would fire a programmer who designs a structure without
>> instance members...
>
>
> :-)  I guess, ***Developer*** posted only the interesting part of the
> structure.
>
>
> Armin
Author
16 Jan 2006 2:50 PM
Armin Zingler
" **Developer**" <REMOVEdevelo***@a-znet.com> schrieb
> I'm beyond worrying about getting fired, but just in case, what the
> problem that Herfried sees?


A structure (object) is a container for data. If there's no data, there's
no need for a structure. I only guess that this is the problem Herfried
sees - and I would agree. In opposite to classes, the singleton pattern
doesn't make sense with structures, in other words, if you don't intend to
create an instance, a class is the better (and only) way to implement it.

Or, in other words, a structure is a value type. A value type without a
value does not make sense.


Armin
Author
16 Jan 2006 3:09 PM
Cor Ligthert [MVP]
Armin,

>
> Or, in other words, a structure is a value type. A value type without a
> value does not make sense.
>
As I was almost writing as well. However than it did look me to silly to
write, as you I assumed that it was partial code.

Cor
Author
16 Jan 2006 4:41 PM
Armin Zingler
"Cor Ligthert [MVP]" <notmyfirstn***@planet.nl> schrieb
> Armin,
>
> >
> > Or, in other words, a structure is a value type. A value type
> > without a value does not make sense.
> >
> As I was almost writing as well. However than it did look me to
> silly to write, as you I assumed that it was partial code.

Pardon?


Armin
Author
16 Jan 2006 3:13 PM
Cor Ligthert [MVP]
Armin,

Did you know that this way of coding is the way were Cobol is very much
based on. Therefore it is maybe not impossible that some developpers still
use (mimic) it. (Giving the same memory area different names and different
structures).

Cor
Author
16 Jan 2006 4:42 PM
Armin Zingler
"Cor Ligthert [MVP]" <notmyfirstn***@planet.nl> schrieb
> Armin,
>
> Did you know that this way of coding is the way were Cobol is very
> much based on.

No, I don't know Cobo.

> Therefore it is maybe not impossible that some
> developpers still use (mimic) it. (Giving the same memory area
> different names and different structures).

Sorry Cor, I don't see the relation to the topic.


ARmin
Author
16 Jan 2006 4:55 PM
**Developer**
Is the objection because there is only on variable.

Actually there were two variables.

One Integer array and one String array.

I think the struct mapped an id (integer) into a name (string).

The string array had the same format as the integer so I tried to simplify
the post.

Is the objection because there is only on variable and is that what you
meant by "singleton pattern"?


thanks


"Armin Zingler" <az.nospam@freenet.de> wrote in message
news:uFYb7wqGGHA.2320@TK2MSFTNGP11.phx.gbl...
>" **Developer**" <REMOVEdevelo***@a-znet.com> schrieb
>> I'm beyond worrying about getting fired, but just in case, what the
>> problem that Herfried sees?
>
>
> A structure (object) is a container for data. If there's no data, there's
> no need for a structure.

Seems to me there is data - the array of integers. On the other hand putting
the array into a structure does not seem to add anything unless there are
other variables in the structure and you want to indentify them as being
related.

I think I'm missing something here.

Show quoteHide quote
> I only guess that this is the problem Herfried
> sees - and I would agree. In opposite to classes, the singleton pattern
> doesn't make sense with structures, in other words, if you don't intend to
> create an instance, a class is the better (and only) way to implement it.
>
> Or, in other words, a structure is a value type. A value type without a
> value does not make sense.
>
>
> Armin
>
Author
16 Jan 2006 5:39 PM
Armin Zingler
Show quote Hide quote
" **Developer**" <REMOVEdevelo***@a-znet.com> schrieb
> Is the objection because there is only on variable.
>
> Actually there were two variables.
>
> One Integer array and one String array.
>
> I think the struct mapped an id (integer) into a name (string).
>
> The string array had the same format as the integer so I tried to
> simplify the post.
>
> Is the objection because there is only on variable and is that what
> you meant by "singleton pattern"?


The point is that there was /no/ /instance/ variable. But, ask Herfried, it
was his statement.


Armin
Author
16 Jan 2006 6:15 PM
Herfried K. Wagner [MVP]
" **Developer**" <REMOVEdevelo***@a-znet.com> schrieb:
> Is the objection because there is only on variable.
>
> Actually there were two variables.

Two shared variables!

> One Integer array and one String array.
>
> I think the struct mapped an id (integer) into a name (string).
>
> The string array had the same format as the integer so I tried to simplify
> the post.
>
> Is the objection because there is only on variable

The problem I see is that the variable is not an instance variable.
Instead, it's a shared variable.  So it's irrelevant if you declare the
variable in a structure or a class.  I suggest to post the complete code
listing and describe in more detail what you want to archieve.  You may want
to include the full C# snippet too.

--
M S   Herfried K. Wagner
M V P  <URL:http://dotnet.mvps.org/>
V B   <URL:http://classicvb.org/petition/>
Author
16 Jan 2006 6:12 PM
Herfried K. Wagner [MVP]
"Armin Zingler" <az.nospam@freenet.de> schrieb:
>> I'm beyond worrying about getting fired, but just in case, what the
>> problem that Herfried sees?
>
> A structure (object) is a container for data. If there's no data, there's
> no need for a structure. I only guess that this is the problem Herfried
> sees - and I would agree. In opposite to classes, the singleton pattern
> doesn't make sense with structures, in other words, if you don't intend to
> create an instance, a class is the better (and only) way to implement it.

Full ACK.

--
M S   Herfried K. Wagner
M V P  <URL:http://dotnet.mvps.org/>
V B   <URL:http://classicvb.org/petition/>
Author
16 Jan 2006 8:15 PM
m.posseth
ACK   hmmmmm ACK =  0x06    ;-)

regards

Michel

Show quoteHide quote
"Herfried K. Wagner [MVP]" <hirf-spam-me-here@gmx.at> wrote in message
news:u1UcyhsGGHA.596@TK2MSFTNGP10.phx.gbl...
> "Armin Zingler" <az.nospam@freenet.de> schrieb:
>>> I'm beyond worrying about getting fired, but just in case, what the
>>> problem that Herfried sees?
>>
>> A structure (object) is a container for data. If there's no data, there's
>> no need for a structure. I only guess that this is the problem Herfried
>> sees - and I would agree. In opposite to classes, the singleton pattern
>> doesn't make sense with structures, in other words, if you don't intend
>> to
>> create an instance, a class is the better (and only) way to implement it.
>
> Full ACK.
>
> --
> M S   Herfried K. Wagner
> M V P  <URL:http://dotnet.mvps.org/>
> V B   <URL:http://classicvb.org/petition/>