I have the following code:
Function TruncateString(str, n)
' Returns an array with strings no more than n char long, truncated at spaces
Dim truncatedArr() As String
If str <> "" Then
str = remove_spaces_left(str)
For i = 0 To (CLng(Len(str) / n))
Index = InStrRev(Left(str, n), " ")
ReDim Preserve truncatedArr(i)
truncatedArr(i) = Left(str, Index)
If Right(truncatedArr(i), 1) = " " Then truncatedArr(i) = Left(truncatedArr(i), Len(truncatedArr(i)) - 1)
str = Right(str, Len(str) - Index)
Next i
End If
TruncateString = truncatedArr
End Function
My question is what is the value returned by the function when str is empty? I have a type compatibility issue when I do
arr = TruncateString (text,15)
arr is defined like this:
dim arr() as string
please let me know if more info is needed for an answer. Thanks