How to determine array size?

Results 1 to 2 of 2

Thread: How to determine array size?

  1. #1
    Join Date
    Dec 1969

    Default How to determine array size?

    Here is the scenorio... I use the Split function to create an array of strings from one big string.<BR> strArray = split(inputString, strDelim, -1, 1)<BR>How can I determine how many elements are in strArray?<BR><BR>Thank you in advance!!!!

  2. #2
    help files Guest

    Default RE: How to determine array size?

    UBound Function<BR>Description<BR><BR>Returns a Long containing the largest available subscript for the indicated dimension of an array.<BR><BR>Syntax<BR><BR>UBound(arrayname[, dimension])<BR><BR>The UBound function syntax has these parts:<BR><BR>Part<BR> Description<BR> <BR><BR> <BR>arrayname<BR> Required, Name of the array variable; follows standard variable naming conventions.<BR> <BR>dimension<BR> Optional; Variant (Long). Whole number indicating which dimension&#039;s upper bound is returned. Use 1 for the first dimension, 2 for the second, and so on. If dimension is omitted, 1 is assumed.<BR> <BR><BR><BR><BR>Remarks<BR><BR>The UBound function is used with the LBound function to determine the size of an array. Use the LBound function to find the lower limit of an array dimension.<BR><BR>UBound returns the following values for an array with these dimensions:<BR><BR>Dim A(1 To 100, 0 To 3, -3 To 4)<BR>Statement<BR> Return Value<BR> <BR><BR> <BR>UBound(A, 1)<BR> 100<BR> <BR>UBound(A, 2)<BR> 3<BR> <BR>UBound(A, 3)<BR> 4<BR> <BR><BR><BR><BR>See Also<BR><BR>Dim statement, LBound function, Option Base statement, Public statement, ReDim statement.<BR><BR>Example<BR><BR>This example uses the UBound function to determine the largest available subscript for the indicated dimension of an array.<BR><BR>Dim Upper<BR>Dim MyArray(1 To 10, 5 To 15, 10 To 20) &#039; Declare array variables.<BR>Dim AnyArray(10)<BR>Upper = UBound(MyArray, 1) &#039; Returns 10.<BR>Upper = UBound(MyArray, 3) &#039; Returns 20.<BR>Upper = UBound(AnyArray) &#039; Returns 10.<BR>Example (Microsoft Excel)<BR><BR>This example writes the elements of the first custom list in column one on Sheet1.<BR><BR>listArray = Application.GetCustomListContents(1)<BR>For i = LBound(listArray, 1) To UBound(listArray, 1)<BR> Worksheets("sheet1").Cells(i, 1).Value = listArray(i)<BR>Next i<BR>This example assumes that you used an external data source to create a PivotTable on Sheet1. The example inserts the SQL connection string and query string into a new worksheet.<BR><BR>Set newSheet = ActiveWorkbook.Worksheets.Add<BR>sdArray = Worksheets("Sheet1").UsedRange.PivotTable.SourceDa ta<BR>For i = LBound(sdArray) To UBound(sdArray)<BR> newSheet.Cells(i, 1) = sdArray(i)<BR>Next i<BR>

Posting Permissions

  • You may not post new threads
  • You may not post replies
  • You may not post attachments
  • You may not edit your posts