[lnkForumImage]
TotalShareware - Download Free Software

Confronta i prezzi di migliaia di prodotti.
Asp Forum
 Home | Login | Register | Search 


 

GS

12/21/2011 6:33:00 PM

I'm looking for an efficient way to get the UBound for all dims of a
multi-dim array. Any suggestions would be greatly appreciated.

Thanks in advance...

--
Garry

Free usenet access at http://www.eternal-sep...
ClassicVB Users Regroup! comp.lang.basic.visual.misc


10 Answers

MikeD

12/21/2011 7:00:00 PM

0


"GS" <gs@somewhere.net> wrote in message news:jct8o5$33p$1@dont-email.me...
> I'm looking for an efficient way to get the UBound for all dims of a
> multi-dim array. Any suggestions would be greatly appreciated.
>


The UBound function has an optional parameter for specifying which dimension
(as does the LBound function). I'm guessing there must be more to your
question than just that.

--
Mike


GS

12/21/2011 7:19:00 PM

0

MikeD expressed precisely :
> "GS" <gs@somewhere.net> wrote in message news:jct8o5$33p$1@dont-email.me...
>> I'm looking for an efficient way to get the UBound for all dims of a
>> multi-dim array. Any suggestions would be greatly appreciated.
>>
>
>
> The UBound function has an optional parameter for specifying which dimension
> (as does the LBound function). I'm guessing there must be more to your
> question than just that.

Thanks Mike!
Yes, I know how to determine the UBound for each dim if dims are known.
Since I've always built my own multi-dim arrays from scratch I've been
able to determine how many dims and so can query UBound(arr, 1),
UBound(arr, 2), and so on if I already know how many dims.

What I'm looking for is a way to determine how many dims an unknown
array is. Currently I use a Do...Loop with a counter that exits when a
trapped error occurs. I don't think I'd ever encounter more than a 3D
array, but a generic method to determine how many dims and how to get
their respective ubounds is what I'm hoping someone can help me with.

--
Garry

Free usenet access at http://www.eternal-sep...
ClassicVB Users Regroup! comp.lang.basic.visual.misc


Thorsten Albers

12/21/2011 9:09:00 PM

0

GS <gs@somewhere.net> schrieb im Beitrag <jctbf4$kpb$1@dont-email.me>...
> What I'm looking for is a way to determine how many dims an unknown
> array is. Currently I use a Do...Loop with a counter that exits when a
> trapped error occurs. I don't think I'd ever encounter more than a 3D
> array, but a generic method to determine how many dims and how to get
> their respective ubounds is what I'm hoping someone can help me with.

Try SafeArrayGetDim() (OLEAUT32.DLL).

--
Thorsten Albers

gudea at gmx.de

GS

12/21/2011 9:21:00 PM

0

It happens that Thorsten Albers formulated :
> GS <gs@somewhere.net> schrieb im Beitrag <jctbf4$kpb$1@dont-email.me>...
>> What I'm looking for is a way to determine how many dims an unknown
>> array is. Currently I use a Do...Loop with a counter that exits when a
>> trapped error occurs. I don't think I'd ever encounter more than a 3D
>> array, but a generic method to determine how many dims and how to get
>> their respective ubounds is what I'm hoping someone can help me with.
>
> Try SafeArrayGetDim() (OLEAUT32.DLL).

Thank you! I'll take a look at that function. There's really not much
call to get this info unless a variant passed to a 3rd party component
returns a multi-dim array. As I explained to MikeD, I currently loop
arrays with unknown dims to do this but would like to find a better way
to handle this task. I appreciate your input...

--
Garry

Free usenet access at http://www.eternal-sep...
ClassicVB Users Regroup! comp.lang.basic.visual.misc


ralph

12/22/2011 2:25:00 AM

0

On Wed, 21 Dec 2011 16:21:23 -0500, GS <gs@somewhere.net> wrote:

>It happens that Thorsten Albers formulated :
>> GS <gs@somewhere.net> schrieb im Beitrag <jctbf4$kpb$1@dont-email.me>...
>>> What I'm looking for is a way to determine how many dims an unknown
>>> array is. Currently I use a Do...Loop with a counter that exits when a
>>> trapped error occurs. I don't think I'd ever encounter more than a 3D
>>> array, but a generic method to determine how many dims and how to get
>>> their respective ubounds is what I'm hoping someone can help me with.
>>
>> Try SafeArrayGetDim() (OLEAUT32.DLL).
>
>Thank you! I'll take a look at that function. There's really not much
>call to get this info unless a variant passed to a 3rd party component
>returns a multi-dim array. As I explained to MikeD, I currently loop
>arrays with unknown dims to do this but would like to find a better way
>to handle this task. I appreciate your input...

It depends on what you are doing with the information, but in most
cases you don't actually need to know the exact dimensions.

You can do a For...Each for each 'sub-array' and trap the error when
you advance one too far.

-ralph

GS

12/22/2011 4:11:00 AM

0

It happens that ralph formulated :
> On Wed, 21 Dec 2011 16:21:23 -0500, GS <gs@somewhere.net> wrote:
>
>> It happens that Thorsten Albers formulated :
>>> GS <gs@somewhere.net> schrieb im Beitrag <jctbf4$kpb$1@dont-email.me>...
>>>> What I'm looking for is a way to determine how many dims an unknown
>>>> array is. Currently I use a Do...Loop with a counter that exits when a
>>>> trapped error occurs. I don't think I'd ever encounter more than a 3D
>>>> array, but a generic method to determine how many dims and how to get
>>>> their respective ubounds is what I'm hoping someone can help me with.
>>>
>>> Try SafeArrayGetDim() (OLEAUT32.DLL).
>>
>> Thank you! I'll take a look at that function. There's really not much
>> call to get this info unless a variant passed to a 3rd party component
>> returns a multi-dim array. As I explained to MikeD, I currently loop
>> arrays with unknown dims to do this but would like to find a better way
>> to handle this task. I appreciate your input...
>
> It depends on what you are doing with the information, but in most
> cases you don't actually need to know the exact dimensions.
>
> You can do a For...Each for each 'sub-array' and trap the error when
> you advance one too far.
>
> -ralph

Thanks Ralph! As I mentioned to MikeD, that's how I do it now only
using a Do...Loop Until Err > 0. Seems to serve the need and so I'll
continue with that for now. When I get time I'll look into Thorsten's
suggestion.

Thanks for your input. I really appreciate your contributions here...

--
Garry

Free usenet access at http://www.eternal-sep...
ClassicVB Users Regroup! comp.lang.basic.visual.misc


(nobody)

12/22/2011 12:18:00 PM

0

"GS" <gs@somewhere.net> wrote in message news:jctikl$3nu$1@dont-email.me...
> It happens that Thorsten Albers formulated :
>> GS <gs@somewhere.net> schrieb im Beitrag <jctbf4$kpb$1@dont-email.me>...
>>> What I'm looking for is a way to determine how many dims an unknown
>>> array is. Currently I use a Do...Loop with a counter that exits when a
>>> trapped error occurs. I don't think I'd ever encounter more than a 3D
>>> array, but a generic method to determine how many dims and how to get
>>> their respective ubounds is what I'm hoping someone can help me with.
>>
>> Try SafeArrayGetDim() (OLEAUT32.DLL).
>
> Thank you! I'll take a look at that function. There's really not much call
> to get this info unless a variant passed to a 3rd party component returns
> a multi-dim array.

It's not just for variants. Sample code has already been written:

http://groups.google.com/group/microsoft.public.vb.winapi.networks/msg/a94088...


GS

12/22/2011 1:49:00 PM

0

Nobody expressed precisely :
> "GS" <gs@somewhere.net> wrote in message news:jctikl$3nu$1@dont-email.me...
>> It happens that Thorsten Albers formulated :
>>> GS <gs@somewhere.net> schrieb im Beitrag <jctbf4$kpb$1@dont-email.me>...
>>>> What I'm looking for is a way to determine how many dims an unknown array
>>>> is. Currently I use a Do...Loop with a counter that exits when a trapped
>>>> error occurs. I don't think I'd ever encounter more than a 3D array, but
>>>> a generic method to determine how many dims and how to get their
>>>> respective ubounds is what I'm hoping someone can help me with.
>>>
>>> Try SafeArrayGetDim() (OLEAUT32.DLL).
>>
>> Thank you! I'll take a look at that function. There's really not much call
>> to get this info unless a variant passed to a 3rd party component returns a
>> multi-dim array.
>
> It's not just for variants. Sample code has already been written:
>
> http://groups.google.com/group/microsoft.public.vb.winapi.networks/msg/a94088...

Thanks very much! This is similar to Thorsten's suggestion and is
definitely worth having. I really appreciate you sharing this...

--
Garry

Free usenet access at http://www.eternal-sep...
ClassicVB Users Regroup! comp.lang.basic.visual.misc


bart.smissaert@gmail.com

1/19/2012 12:14:00 AM

0

This is a nice way to get the number of dimensions of an array:
http://www.devx.com/vb2themax...

RBS


"GS" <gs@somewhere.net> wrote in message news:jct8o5$33p$1@dont-email.me...
> I'm looking for an efficient way to get the UBound for all dims of a
> multi-dim array. Any suggestions would be greatly appreciated.
>
> Thanks in advance...
>
> --
> Garry
>
> Free usenet access at http://www.eternal-sep...
> ClassicVB Users Regroup! comp.lang.basic.visual.misc
>
>

GS

1/19/2012 12:27:00 AM

0

RB Smissaert formulated on Wednesday :
> This is a nice way to get the number of dimensions of an array:
> http://www.devx.com/vb2themax...
>
> RBS

Very nice indeed! Thank you for sharing this wth me...

regards,

--
Garry

Free usenet access at http://www.eternal-sep...
ClassicVB Users Regroup! comp.lang.basic.visual.misc