Home | Contact Us | FAQ | Search & Site Map | Link to Us
Sign In | Join | Other 45 Sites in Network
Home
Discussion GroupsVB SyntaxEnterprise DevelopmentDatabase AccessControlsCOMWin APICrystal ReportDeploymentGeneralGeneral 2
Related Topics
VB.NET / ASP.NETMS SQL ServerMS AccessOther Database ProductsMore Topics ...

VB Forum / General / February 2005



Tip: Looking for answers? Try searching our database.

Size of array

Thread view: 
Enable EMail Alerts  Start New Thread
Thread rating: 
Johan van Hespen - 27 Feb 2005 20:39 GMT
Hi folks,

Is there a simple method for finding the size of  any type of array
(strings, user types etc.)
Mike D Sutton - 27 Feb 2005 21:24 GMT
> Is there a simple method for finding the size of  any type of array
> (strings, user types etc.)

Have a look at the VarType() method.
Note; the vbArray value is a _flag_ as opposed to the other values which are discreet values, i.e. vbInteger = Integer,
vbInteger Or vbArray = Integer().
You can test for an array using "VarType(Array()) Or vbArray" or if you want to know the variable type regardless of
whether it's an array or not then use "VarType(Array()) And (Not vbArray)".
Also note that UDT's cannot be cast to a variant and as such if you have an array of UDT then you should know it's an
array of UDT's because you have to declare them that way...
Hope this helps,

   Mike

- Microsoft Visual Basic MVP -
E-Mail: EDais@mvps.org
WWW: Http://EDais.mvps.org/
Mike D Sutton - 27 Feb 2005 21:27 GMT
> Is there a simple method for finding the size of  any type of array
> (strings, user types etc.)

And after actually _reading_ the question...  You can use LBound() and UBound() to get the size of each dimension of the
array, or use hack around with the array descriptor:
http://vbnet.mvps.org/code/helpers/getarraydims.htm
Hope this helps,

   Mike

- Microsoft Visual Basic MVP -
E-Mail: EDais@mvps.org
WWW: Http://EDais.mvps.org/
Johan van Hespen - 28 Feb 2005 22:02 GMT
I was wondering if there was a simple function that returns the size in
bytes of memory occupied by the variable. I think I have to do it the hard
way with ubound and lenb and so on...
THanks anyway...

>> Is there a simple method for finding the size of  any type of array
>> (strings, user types etc.)
[quoted text clipped - 10 lines]
> E-Mail: EDais@mvps.org
> WWW: Http://EDais.mvps.org/
Mike D Sutton - 28 Feb 2005 22:40 GMT
> I was wondering if there was a simple function that returns the size in
> bytes of memory occupied by the variable. I think I have to do it the hard
> way with ubound and lenb and so on...
> THanks anyway...

Use the SAFEARRAY trick, much easier IMO than LBound()/UBound().
Hope this helps,

   Mike

- Microsoft Visual Basic MVP -
E-Mail: EDais@mvps.org
WWW: Http://EDais.mvps.org/
 
Sign In
Join
My Latest Posts
My Monitored Threads
My Blog
My Photo Gallery
My Profile
My Homepage

Start New Thread
Enable EMail Alerts
Rate this Thread



©2009 Advenet LLC   Privacy Policy - Terms of Use
This website includes both content owned or controlled by Advenet as well as content owned or controlled by third parties.