You could also use a Collection as your container which dynamically resizes itself.
This version would also take any or no delimiter.
[code]
Function StringToDoubleArray(inString As String) As Double()
Dim dblColl As New Collection
Dim i As Integer
For i = 0 To VBA.Len(inString)
If VBA.IsNumeric(VBA.Mid(inString, i + 1, 1)) Then
dblColl.Add VBA.Mid(inString, i + 1, 1)
End If
Next i
ReDim scratch(dblColl.Count - 1) As Double
For i = 0 To dblColl.Count - 1
scratch(i) = dblColl(i + 1)
Next i
StringToDoubleArray = scratch
End Function
[/code]
"Paul Richardson" wrote in message news:5870497@discussion.autodesk.com...
[code]
Sub driver()
Dim pl As AcadLWPolyline
Set pl = ThisDrawing.ModelSpace.AddLightWeightPolyline _
(StringToDoubleArray("1,1,2,2,0,2"))
pl.Closed = True
End Sub
Function StringToDoubleArray(inString As String)
'you could avoid using split and just loop
'the string but you would need to keep calling
'redim. Would be good practice to try looping
'the string though. Look into VBA.Mid, VBA.Len, ...
Dim strArr
strArr = VBA.Split(inString, ",")
ReDim dblArr(UBound(strArr)) As Double
Dim i As Integer
For i = 0 To UBound(strArr)
If VBA.IsNumeric(strArr(i)) Then
dblArr(i) = strArr(i)
Else
'Solve the problem
End If
Next i
StringToDoubleArray = dblArr
End Function
[/code]
wrote in message news:5870504@discussion.autodesk.com...
Set ObjPolyline = Thisdrawing.modelspace.AddPolyline (Richtextbox1.text)
Note: The RichTextbox is multiline and the contents are
X,Y
X,Y
X,Y
X,Y
X,Y
X,Y
I also have a string named TEMPSTRING
TEMPSTRING = X,Y,X,Y,X,Y,X,Y,X,Y
The above doesn't work.
I need a continuous polyline using either the Richtextbox1.text contents OR by using the TempString