[AccessD] Determine the number of columns in an array

Jim DeMarco Jdemarco at hshhp.org
Thu Jul 3 10:42:31 CDT 2003


You can't count on Ubound (or Ubound + 1) to give the correct number of elements in array for example:
 Dim sarrNames(2 to 10)
would return 10 as the upper bound but there are actually only 9 elements in this array.

Here's one way to get the true value (try with each variable declaration):

Function ArrayNumElements() As Long
Dim sarrNames(10)
'Dim sarrNames(2 to 10)
    ArrayNumElements = UBound(sarrNames) - LBound(sarrNames) + 1
End Function

HTH,

Jim DeMarco
Director of Product Development
HealthSource/Hudson Health Plan


-----Original Message-----
From: Mark H [mailto:lists at theopg.com]
Sent: Thursday, July 03, 2003 11:32 AM
To: 'Access Developers discussion and problem solving'
Subject: [AccessD] Determine the number of columns in an array


Hello all...

Sorry if this is a bit simple, but I'm in a bit of a rush to get out and
wanted to ask before I go (climbing - yippeeee)...

Anyway, does anyone know how to determine the number of columns in an
array? I am trying to write a bit of generic code and want to be able to
pass the array and then figure out its width. I looked in the helps "See
also" under Lbound and Ubound but found nothing...

Thanks in advance

Mark

_______________________________________________
AccessD mailing list
AccessD at databaseadvisors.com
http://databaseadvisors.com/mailman/listinfo/accessd
Website: http://www.databaseadvisors.com


***********************************************************************************
"This electronic message is intended to be for the use only of the named recipient, and may contain information from Hudson Health Plan (HHP) that is confidential or privileged.  If you are not the intended recipient, you are hereby notified that any disclosure, copying, distribution or use of the contents of this message is strictly prohibited.  If you have received this message in error or are not the named recipient, please notify us immediately, either by contacting the sender at the electronic mail address noted above or calling HHP at (914) 631-1611. If you are not the intended recipient, please do not forward this email to anyone, and delete and destroy all copies of this message.  Thank You".
***********************************************************************************



More information about the AccessD mailing list