Results 1 to 5 of 5

Thread: Counting the number of elements in an array...

  1. #1

    Thread Starter
    Addicted Member
    Join Date
    May 1999
    Location
    Californ-I- A
    Posts
    207

    Post

    Perhaps a simple question, bu can anyone tell me the simplist way to count the depth of my array ... like the count method in the collection class.

    Do I have to loop through until an error is raised to determine how many of an array I have?

  2. #2
    I'm about to be a PowerPoster! Joacim Andersson's Avatar
    Join Date
    Jan 1999
    Location
    Sweden
    Posts
    14,649

    Post

    If you have an array of a primitive data type (like Integer or Single) then use the UBound and LBound functions:
    Code:
    MsgBox "Number of items in the array: " & UBound(MyArray) - LBound(MyArray) + 1
    If it's a control array use the Count method or the UBound and LBound methods.

    Good luck!


    Edited by Joacim Andersson on 02-24-2000 at 12:52 PM

  3. #3

    Thread Starter
    Addicted Member
    Join Date
    May 1999
    Location
    Californ-I- A
    Posts
    207

    Post

    Thank you, but it's actually an array of strings.

    To be specific, it's an array created using Split() to separate folders froma path. ("C:\Windows\System\" becomes "C:", "Windows", and "System".

  4. #4

    Thread Starter
    Addicted Member
    Join Date
    May 1999
    Location
    Californ-I- A
    Posts
    207

    Post

    Nevermind ... UBound works.

  5. #5
    I'm about to be a PowerPoster! Joacim Andersson's Avatar
    Join Date
    Jan 1999
    Location
    Sweden
    Posts
    14,649

    Post

    Primitive Data Types are:

    Byte
    Integer
    Long
    Single
    Double
    Currency
    String
    Variant
    Date
    Boolean

Posting Permissions

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



Click Here to Expand Forum to Full Width