LinkBack Thread Tools Search this Thread Display Modes
Prev Previous Post   Next Post Next
  #1   Report Post  
Posted to microsoft.public.excel.programming
external usenet poster
 
Posts: 22
Default Can't figure out passing and returning arrays

I'm trying to make my function return an array of strings and can't
seem to get it to work. I get Error 9, subscript out of range. The
error occurs on the line "strArray(i) = str"
Here is the relevant part of the code:

Sub CompareLabels(str1 as String)
Dim strWords1() As String
strWords1 = MakeArrayOfWords(str1)
End Sub

Private Function MakeArrayOfWords(ByVal str As String) As String()

Dim i As Integer, intSpace As Integer, intLength As Integer,
strArray() As String
If str < "" Then
Do
i = i + 1
intSpace = InStr(1, str, " ", vbTextCompare)
If intSpace 0 Then
strArray(i) = Left(str, intSpace)
intLength = Len(str) - intSpace
str = Right(str, intLength)
Else
strArray(i) = str
End If
Loop Until intSpace = 0
MakeArrayOfWords = strArray
End If

End Function


Can anyone help? Thanks.

P.S. I suck at working with arrays.

 
Thread Tools Search this Thread
Search this Thread:

Advanced Search
Display Modes

Posting Rules

Smilies are On
[IMG] code is On
HTML code is Off
Trackbacks are On
Pingbacks are On
Refbacks are On


Similar Threads
Thread Thread Starter Forum Replies Last Post
Passing arrays to VBA module Ralph K Excel Programming 1 November 20th 04 02:57 PM
Ranges and Arrays - Passing values Don Lloyd Excel Programming 4 October 19th 04 03:18 AM
Passing variant arrays to C/C++ dll's agarwaldvk[_35_] Excel Programming 0 October 18th 04 01:33 AM
passing arrays between functions in VBA Tom Ogilvy Excel Programming 3 March 1st 04 05:54 PM
Passing arrays to a subroutine Braden Craig Excel Programming 4 August 17th 03 05:54 PM


All times are GMT +1. The time now is 04:03 AM.

Powered by vBulletin® Copyright ©2000 - 2025, Jelsoft Enterprises Ltd.
Copyright ©2004-2025 ExcelBanter.
The comments are property of their posters.
 

About Us

"It's about Microsoft Excel"