+ Reply to Thread
Results 1 to 2 of 2

Count number of different value in vector

  1. #1
    Alex St-Pierre
    Guest

    Count number of different value in vector

    Hi,
    I have a vector of 6 to 20 elements which is declared:
    Dim file(20) as string

    I would like to count how many different text is include in the vector

    file(20).differentvalue.count

    I know that I can use an algor. to count it but I would like to have
    something smaller.
    Thanks,

    --
    Alex St-Pierre

  2. #2
    Chip Pearson
    Guest

    Re: Count number of different value in vector

    Alex,

    Try something like the following:

    Dim C As New Collection
    Dim Ndx As Long
    On Error Resume Next
    For Ndx = 1 To 20
    C.Add file(Ndx), file(Ndx)
    Next Ndx
    Debug.Print "Different strings: " & C.Count


    --
    Cordially,
    Chip Pearson
    Microsoft MVP - Excel
    Pearson Software Consulting, LLC
    www.cpearson.com


    "Alex St-Pierre" <[email protected]> wrote
    in message
    news:[email protected]...
    > Hi,
    > I have a vector of 6 to 20 elements which is declared:
    > Dim file(20) as string
    >
    > I would like to count how many different text is include in the
    > vector
    >
    > file(20).differentvalue.count
    >
    > I know that I can use an algor. to count it but I would like to
    > have
    > something smaller.
    > Thanks,
    >
    > --
    > Alex St-Pierre




+ 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