count array element in word vba

Tech-Archive recommends: Repair Windows Errors & Optimize Windows Performance

From: scott (scott_at_sporticia.com)
Date: 03/03/04


Date: Wed, 3 Mar 2004 22:30:27 -0000

hi

I have a snippet of code that take a given string and uses 'split' to pop it
into an array for me

the string is being split with the space char as the seperator

the problem is that sometimes the string will contain x2 words, other times
x3 or x4

is there a way to count or return the number of array elements being created
from the split ?

code below

<snip>
'need to split aircraft names up for displayy purposes
                        strAircraft = Trim(AirCraftBox.Value)
                        arrAircraft = Split(strAircraft)

                        'most planes have 3 part names
                        If Count.arrAircraft() > 2 Then
                            strAircraft_Make = arrAircraft(0)
                            strAircraft_Model = arrAircraft(1) & " " &
arrAircraft(2)
                        'gulfs have 2 part names only
                        Else
                            strAircraft_Make = arrAircraft(0) & " " &
arrAircraft(1)
                        End If
</snip>

obviously this is not working, is there a method for dealing with this ? or
will I have to loop through all elements to determin how many there are
(seems a little inefficient that way round !)

thanks

_scott



Relevant Pages

  • Help in French|Spanish|German translation.
    ... I am also an author of User-defined string functions. ... WORDTRANEX (cSearched, cArExpressionSought | cExpressionSough, ... each string of the array is searched ... If the parameter nArStartOccurrence is -1 or omitted, the replacement starts ...
    (microsoft.public.fox.helpwanted)
  • Re: passing a string to a dll
    ... Joe, I really appreciate you taking the time to demonstrate this. ... sure how I would implement indexing it for random alphanumeric codes. ... I might handle the array. ... I actually have been wondering if I could use a second string ...
    (microsoft.public.vc.mfc)
  • Re: passing a string to a dll
    ... I might handle the array. ... I actually have been wondering if I could use a second string ... look at insertion cost, organization cost, and search cost. ...
    (microsoft.public.vc.mfc)
  • RE: Structure conversion from C++ to VB-2008?
    ... One of the most important structures is AmiVar structure. ... point number, the array of floating point numbers, a string or IDispatch ... Dim 13012679 as Integer ...
    (microsoft.public.dotnet.languages.vb)
  • Structure conversion from C++ to VB-2008?
    ... One of the most important structures is AmiVar structure. ... point number, the array of floating point numbers, a string or IDispatch ... Dim 13012679 as Integer ...
    (microsoft.public.dotnet.languages.vb)