Newsgroups: microsoft.public.vb.general.discussion
From: "Mike D Sutton" <Mike.Sut...@btclick.com>
Date: Sun, 12 Jan 2003 20:51:25 -0000
Local: Sun 12 Jan 2003 20:51
Subject: Re: Array Size
> The generic formula is This doesn't take into account multi-dimensional or un-initialised arrays > UBound(MyArray) - LBound(MyArray) + 1 > So, if the array is zero-based then the number of elements becomes > Ubound(MyArray) + 1 > If the array is 1-based then it is just UBound(MyArray). though, for that you'd need something like this: http://www.mvps.org/vbnet/code/helpers/getarraydims.htm Here's another solution for you: '*** Private Function ArrSize(ByRef inArr As Variant, _ Do If (TempDim <> -1) Then With outArr(ArrSize) ArrSize = ArrSize + 1 Private Sub SayArrayDim(ByRef inArr As Variant) NumDims = ArrSize(inArr, ArrDims()) If (NumDims) Then For LoopDims = 0 To NumDims - 1 SayDims = SayDims & ")" MsgBox SayDims Private Sub Form_Load() Call SayArrayDim(MyArr) Hope this helps, Mike -- EDais -- - Microsoft Visual Basic MVP - You must Sign in before you can post messages.
To post a message, you must first join this group.
Please update your nickname on the subscription settings page before posting.
You do not have the permission required to post.
| ||||||||||||||