+ Reply to Thread
Results 1 to 4 of 4

Count quanity of values in an Array

  1. #1
    Simon Shaw
    Guest

    Count quanity of values in an Array

    Hi,

    Dim myArray(54,100) as Sting

    Can I count the number of items in the second dimension of my array...?
    without looping through all 100 possible values and checking to see if they
    are not nulll...

    thanks

    Simon Shaw


  2. #2
    Tom Ogilvy
    Guest

    Re: Count quanity of values in an Array

    What do you mean by the second dimension of the array. Each row has 100
    columns. Each column has 54 rows. What are you trying to check?

    --
    Regards,
    Tom Ogilvy

    "Simon Shaw" <simonATsimonstoolsDOTcom> wrote in message
    news:[email protected]...
    > Hi,
    >
    > Dim myArray(54,100) as Sting
    >
    > Can I count the number of items in the second dimension of my array...?
    > without looping through all 100 possible values and checking to see if

    they
    > are not nulll...
    >
    > thanks
    >
    > Simon Shaw
    >




  3. #3
    Simon Shaw
    Guest

    Re: Count quanity of values in an Array

    I am storing user selection lists from a ListBox in the Array:
    myArray(Filter_Number, Selected_Items)
    where the max filters are 54 and the max selected items is 100.
    Usually the user will select less than 100 items say 10 items for say filter
    1, how can I count the 10 items of the selected_items without looping through
    the array to see if items have been stored?

    I want to avoid:

    for i = 1 to 100
    if myArray(1, i).value <> "" then _
    count = count + 1
    next i

    "Tom Ogilvy" wrote:

    > What do you mean by the second dimension of the array. Each row has 100
    > columns. Each column has 54 rows. What are you trying to check?
    >
    > --
    > Regards,
    > Tom Ogilvy
    >
    > "Simon Shaw" <simonATsimonstoolsDOTcom> wrote in message
    > news:[email protected]...
    > > Hi,
    > >
    > > Dim myArray(54,100) as Sting
    > >
    > > Can I count the number of items in the second dimension of my array...?
    > > without looping through all 100 possible values and checking to see if

    > they
    > > are not nulll...
    > >
    > > thanks
    > >
    > > Simon Shaw
    > >

    >
    >
    >


  4. #4
    Tom Ogilvy
    Guest

    Re: Count quanity of values in an Array

    This counts the number of values a row at a time.

    Sub ABC()
    Dim v(1 To 54, 1 To 100)
    Dim v1 as Variant
    For i = 1 To 10
    For j = 1 To 10
    v(Int(Rnd() * 54 + 1), Int(Rnd() * 100 + 1)) = i * j
    Next
    Next
    For i = 1 To 54
    v1 = Application.Index(v, i, 0)
    Debug.Print i, Application.Count(v1)
    Next
    End Sub

    If the array elements would be alphanumeric, use countA

    --
    Regards,
    Tom Ogilvy


    "Simon Shaw" <simonATsimonstoolsDOTcom> wrote in message
    news:[email protected]...
    > I am storing user selection lists from a ListBox in the Array:
    > myArray(Filter_Number, Selected_Items)
    > where the max filters are 54 and the max selected items is 100.
    > Usually the user will select less than 100 items say 10 items for say

    filter
    > 1, how can I count the 10 items of the selected_items without looping

    through
    > the array to see if items have been stored?
    >
    > I want to avoid:
    >
    > for i = 1 to 100
    > if myArray(1, i).value <> "" then _
    > count = count + 1
    > next i
    >
    > "Tom Ogilvy" wrote:
    >
    > > What do you mean by the second dimension of the array. Each row has 100
    > > columns. Each column has 54 rows. What are you trying to check?
    > >
    > > --
    > > Regards,
    > > Tom Ogilvy
    > >
    > > "Simon Shaw" <simonATsimonstoolsDOTcom> wrote in message
    > > news:[email protected]...
    > > > Hi,
    > > >
    > > > Dim myArray(54,100) as Sting
    > > >
    > > > Can I count the number of items in the second dimension of my

    array...?
    > > > without looping through all 100 possible values and checking to see if

    > > they
    > > > are not nulll...
    > > >
    > > > thanks
    > > >
    > > > Simon Shaw
    > > >

    > >
    > >
    > >




+ Reply to Thread

Thread Information

Users Browsing this Thread

There are currently 1 users browsing this thread. (0 members and 1 guests)

Bookmarks

Posting Permissions

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

Search Engine Friendly URLs by vBSEO 3.6.0 RC 1