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/