array - how do you get the number of dimensions?

  • Thread starter Thread starter Cerebrus99
  • Start date Start date
C

Cerebrus99

Hi,

Array.Rank property will give you the no. of dimensions.

BTW, I think he did post to the dotnet Newsgroup too.

Regards,

Cerebrus.
 
Almost everybody in this newsgroup is using VB6 or lower. While you may get
a stray answer to VB.NET / VB2003 / VB2005 questions here, you should ask
them in newsgroups
devoted exclusively to .NET programming. Look for newsgroups with either the
word "dotnet" or "vsnet" in their name.

For the microsoft news server, try these newsgroups...

microsoft.public.dotnet.general
microsoft.public.dotnet.languages.vb
microsoft.public.vsnet.general


--
Chris Hanscom - Microsoft MVP (VB)
Veign's Resource Center
http://www.veign.com/vrc_main.asp
Veign's Blog
http://www.veign.com/blog
 
I want to check that an array passed in has a certain number of
dimensions - is there a way to check for this in framework 1.1 ?
 
Almost everybody in this newsgroup is using VB6 or lower. While you may get
a stray answer to VB.NET (including VB2003 and VB2005 which has dropped .NET
from its name) questions here, you should ask them in newsgroups devoted
exclusively to .NET programming (the languages are different enough to
warrant separate newsgroup support). Look for newsgroups with either the
word "dotnet" or "vsnet" in their name.

For the microsoft news server, try these newsgroups for Visual Basic .NET
related questions...

microsoft.public.dotnet.languages.vb
microsoft.public.dotnet.languages.vb.upgrade
microsoft.public.dotnet.languages.vb.controls
microsoft.public.dotnet.languages.vb.data

And these for more general .NET questions

microsoft.public.dotnet.general
microsoft.public.vsnet.general

Note: There are many other .NET newgroups (use the first three "fields" from
the last two as templates when searching for them), but the above ones
should get you started.

Rick
 
That's strange, this posting *IS* to
microsoft.public.dotnet.languages.vb

I am using Google newsgroups
http://groups.google.com

maybe it is mistakenly posting and displaying one group as another?
Almost everybody in this newsgroup is using VB6 or lower.
For the microsoft news server, try these newsgroups...
microsoft.public.dotnet.general
microsoft.public.dotnet.languages.vb
microsoft.public.vsnet.general
 
Mad Scientist Jr--

Did you mean that you want to know the allocated size of the array, or
how many values you have put into the array? Also,what type of array
is it: is it an arrayList member or just something like String()?

If it is like an arrayList, then you can just access the property:
arrayList.items.count.

if it is an array like string() then you have two ways to tell. You
can either use:
1) arrayName.length()
The method arrayName.length() will give you the number of elements
available in your array -> the size created. For example if you did :
redim arrayName(9)
then arrayName.length() would return 10.

or

2) UBound(arrayName).
This method returns the upperbound number for your array. For example
if you did:
redim arrayName(9)
then UBound(arrayName) would return 9.

As far as I know, there is not a way to determine from the array the
actual number of elements YOU put into the array declared like
string(), because when you give it an actual size, there is a default
value that is always inserted, so every item actually has a value.

Hope that this helps.
--mhos
 
Mad Scientist Jr said:
I want to check that an array passed in has a certain number of
dimensions - is there a way to check for this in framework 1.1 ?

Check it's Rank property. Usually this is only necessary if the type of the
parameter is 'Array', not integer() or integer(,) which implicitly
determines the number of dimensions.


Armin
 
Yes, rank was what I was looking for.

PS I am posting thru the google newsgroups site (groups.google.com),
and it is saying that this group is
microsoft.public.dotnet.languages.vb - i'm looking at it on my screen
right now.
Go to groups.google.com and search for "array - how do you get the
number of dimensions?" and you'll see the group name... so don't blame
me, blame the goog! It is not my intention to clog up the wrong groups
with irrelevant posts

: )
 
That's strange, this posting *IS* to
microsoft.public.dotnet.languages.vb

I am using Google newsgroups
http://groups.google.com

maybe it is mistakenly posting and displaying one group as another?

I didn't notice the cross-post when I replied (as did others) to your
message. For future reference, the flurry of "wrong group" messages you got
is because you included microsoft.public.vb.general.discussion as one of
your groups. That group IS only meant to be only for the classic versions of
VB.

Rick
 
Just for completeness, and to compound the cross-posting issue (<grin>),
here's some VB-classic info on the same requirement:

The recommended approach is covered in knowledge-base article 152288:
http://support.microsoft.com/?id=152288

However, you can also look directly at the SafeArray descriptor, taking
account of whether it's provided via a Variant, and whether it's a static or
dynamic array (descriptor at different Variant offsets):
http://www.devx.com/vb2themax/Tip/18265

Tony Proctor
 
Back
Top