Home All Groups Group Topic Archive Search About

Copying a User-defined type array

Author
2 Feb 2006 3:13 AM
wxforecaster
Say I have a user defined type:

Type blah
X as String
Y as String
Z as String
etc....
End Type

Now I create an array of this type say,

Dim foo(0 to 10) as blah

If I have a need to re-sort the contents of the array, can I do something as
simple as:

foo(0) = foo(1) or do I need to physically move each variable in the type
structure from one array element to the other?

Thanks in advance,
Eva

Author
2 Feb 2006 3:40 AM
Dmitriy Antonov
Show quote Hide quote
"wxforecaster" <ebookbin***@interwarn.com> wrote in message
news:uFEfha6JGHA.2828@TK2MSFTNGP12.phx.gbl...
> Say I have a user defined type:
>
> Type blah
> X as String
> Y as String
> Z as String
> etc....
> End Type
>
> Now I create an array of this type say,
>
> Dim foo(0 to 10) as blah
>
> If I have a need to re-sort the contents of the array, can I do something
> as simple as:
>
> foo(0) = foo(1) or do I need to physically move each variable in the type
> structure from one array element to the other?
>
> Thanks in advance,
> Eva
>
>
>

You can do it exactly as written.

BTW, the time to check it would be almost equal to that you spent typing
your request <g>

Dmitriy.
Author
2 Feb 2006 3:12 PM
wxforecaster
True true, but it's nice to know that I'm not overlooking something with a
30+ variable type cast :)

Thanks for the confirmation. That saved me a lot of time.

Evan

Show quoteHide quote
"Dmitriy Antonov" <antonovdima@netzero.net_NOT_FOR_SPAM> wrote in message
news:%230wLZp6JGHA.1320@TK2MSFTNGP15.phx.gbl...
>
> "wxforecaster" <ebookbin***@interwarn.com> wrote in message
> news:uFEfha6JGHA.2828@TK2MSFTNGP12.phx.gbl...
>> Say I have a user defined type:
>>
>> Type blah
>> X as String
>> Y as String
>> Z as String
>> etc....
>> End Type
>>
>> Now I create an array of this type say,
>>
>> Dim foo(0 to 10) as blah
>>
>> If I have a need to re-sort the contents of the array, can I do something
>> as simple as:
>>
>> foo(0) = foo(1) or do I need to physically move each variable in the type
>> structure from one array element to the other?
>>
>> Thanks in advance,
>> Eva
>>
>>
>>
>
> You can do it exactly as written.
>
> BTW, the time to check it would be almost equal to that you spent typing
> your request <g>
>
> Dmitriy.
>
Author
2 Feb 2006 3:25 PM
Mike Williams
"wxforecaster" <ebookbin***@interwarn.com> wrote in message
news:%232F8QsAKGHA.524@TK2MSFTNGP09.phx.gbl...

> True true, but it's nice to know that I'm not overlooking
> something with a 30+ variable type cast :)

If you're sorting an array of UDTs of such a size it would be very much
faster to sort and / or swap pointers to the UDTs, rather than sorting /
swapping the UDTs themselves. In such cases an index sort would be probably
about twenty times faster than a straight forward sort.

Mike