Determining array length with split function
- From: EllenM <EllenM@xxxxxxxxxxxxxxxxxxxxxxxxx>
- Date: Mon, 1 Oct 2007 07:36:03 -0700
Hello, I have incorporated the split function to isolate an array of
substrings within a string. It works fine, however, I need a way of
determining the number of substrings in any given array to avoid referencing
an index that is outside the array bounds. For instance, sometimes I could
have 3 substrings or other times 8 substrings. As such, something like the
following would fail for a string with only 3 substrings.
Split(MyData.GetText, vbCr)(5)
Anyone familiar with the split function will know that there is no element 5
in the above example. You get an “array out of bounds” error message or some
such thing. Is there a way of determining in advance the number of substrings
to avoid referencing an item that does not exist? I found Microsoft’s help
section confusing when studying the split() function.
Thanks,
Ellen
.
- Follow-Ups:
- Re: Determining array length with split function
- From: Helmut Weber
- Re: Determining array length with split function
- From: Shauna Kelly
- Re: Determining array length with split function
- Prev by Date: When copy styles to WORD, exclude HEADING STYLES
- Next by Date: Re: Determining array length with split function
- Previous by thread: When copy styles to WORD, exclude HEADING STYLES
- Next by thread: Re: Determining array length with split function
- Index(es):
Relevant Pages
|