<?xml version="1.0" encoding="UTF-8"?>
<rss xmlns:content="http://purl.org/rss/1.0/modules/content/" xmlns:dc="http://purl.org/dc/elements/1.1/" xmlns:rdf="http://www.w3.org/1999/02/22-rdf-syntax-ns#" xmlns:taxo="http://purl.org/rss/1.0/modules/taxonomy/" version="2.0">
  <channel>
    <title>topic Re: Quick Array Question in VBA Forum</title>
    <link>https://forums.autodesk.com/t5/vba-forum/quick-array-question/m-p/1833840#M29517</link>
    <description>Change this line&lt;BR /&gt;
ReDim StrAr(UBound(VarPoints)) As Variant&lt;BR /&gt;
on&lt;BR /&gt;
ReDim StrAr(UBound(VarPoints)) As String&lt;BR /&gt;
&lt;BR /&gt;
Will this helps?&lt;BR /&gt;
&lt;BR /&gt;
~'J'~</description>
    <pubDate>Tue, 05 Dec 2006 16:27:20 GMT</pubDate>
    <dc:creator>Anonymous</dc:creator>
    <dc:date>2006-12-05T16:27:20Z</dc:date>
    <item>
      <title>Quick Array Question</title>
      <link>https://forums.autodesk.com/t5/vba-forum/quick-array-question/m-p/1833838#M29515</link>
      <description>I have this function which splits a string and converts it to an array.  It works fine with numbers, but when the entry becomes text it doesn't seem to work.  What is wrong with my code?&lt;BR /&gt;
&lt;BR /&gt;
IF varpoints = "Double,Array"&lt;BR /&gt;
&lt;BR /&gt;
Function stringToDblArray(VarPoints)&lt;BR /&gt;
Dim StrAr() As Variant&lt;BR /&gt;
  VarPoints = VBA.Split(VarPoints, ",")&lt;BR /&gt;
  If IsNumeric(VarPoints) Then&lt;BR /&gt;
  ReDim ptaRr(UBound(VarPoints)) As Double&lt;BR /&gt;
  &lt;BR /&gt;
  Dim i As Integer&lt;BR /&gt;
  For i = 0 To UBound(VarPoints)&lt;BR /&gt;
    ptaRr(i) = CDbl(VarPoints(i))&lt;BR /&gt;
  Next i&lt;BR /&gt;
  Else&lt;BR /&gt;
  ReDim StrAr(UBound(VarPoints)) As Variant&lt;BR /&gt;
  For i = 0 To UBound(VarPoints)&lt;BR /&gt;
    StrAr(i) = CStr(VarPoints(i))&lt;BR /&gt;
  Next i&lt;BR /&gt;
  End If&lt;BR /&gt;
  stringToDblArray = ptaRr&lt;BR /&gt;
  &lt;BR /&gt;
End Function</description>
      <pubDate>Tue, 05 Dec 2006 15:29:18 GMT</pubDate>
      <guid>https://forums.autodesk.com/t5/vba-forum/quick-array-question/m-p/1833838#M29515</guid>
      <dc:creator>Anonymous</dc:creator>
      <dc:date>2006-12-05T15:29:18Z</dc:date>
    </item>
    <item>
      <title>Re: Quick Array Question</title>
      <link>https://forums.autodesk.com/t5/vba-forum/quick-array-question/m-p/1833839#M29516</link>
      <description>Because of IsNumeric, your logic will never enter the If structure when the argument is text.</description>
      <pubDate>Tue, 05 Dec 2006 16:26:55 GMT</pubDate>
      <guid>https://forums.autodesk.com/t5/vba-forum/quick-array-question/m-p/1833839#M29516</guid>
      <dc:creator>Ed__Jobe</dc:creator>
      <dc:date>2006-12-05T16:26:55Z</dc:date>
    </item>
    <item>
      <title>Re: Quick Array Question</title>
      <link>https://forums.autodesk.com/t5/vba-forum/quick-array-question/m-p/1833840#M29517</link>
      <description>Change this line&lt;BR /&gt;
ReDim StrAr(UBound(VarPoints)) As Variant&lt;BR /&gt;
on&lt;BR /&gt;
ReDim StrAr(UBound(VarPoints)) As String&lt;BR /&gt;
&lt;BR /&gt;
Will this helps?&lt;BR /&gt;
&lt;BR /&gt;
~'J'~</description>
      <pubDate>Tue, 05 Dec 2006 16:27:20 GMT</pubDate>
      <guid>https://forums.autodesk.com/t5/vba-forum/quick-array-question/m-p/1833840#M29517</guid>
      <dc:creator>Anonymous</dc:creator>
      <dc:date>2006-12-05T16:27:20Z</dc:date>
    </item>
    <item>
      <title>Re: Quick Array Question</title>
      <link>https://forums.autodesk.com/t5/vba-forum/quick-array-question/m-p/1833841#M29518</link>
      <description>I've tried changing from Variant to String and it still gives me an error subscript out of range.&lt;BR /&gt;
&lt;BR /&gt;
Could i possibly check each index of varpoints before it redim's to see if it is numeric since isnumeric will prevent it from ever entering the if statement?</description>
      <pubDate>Tue, 05 Dec 2006 17:08:24 GMT</pubDate>
      <guid>https://forums.autodesk.com/t5/vba-forum/quick-array-question/m-p/1833841#M29518</guid>
      <dc:creator>Anonymous</dc:creator>
      <dc:date>2006-12-05T17:08:24Z</dc:date>
    </item>
    <item>
      <title>Re: Quick Array Question</title>
      <link>https://forums.autodesk.com/t5/vba-forum/quick-array-question/m-p/1833842#M29519</link>
      <description>First, you pass wrong variable into Split function&lt;BR /&gt;
See help. This would be a string expression not a variant&lt;BR /&gt;
Try this one, seems to be working for me&lt;BR /&gt;
&lt;BR /&gt;
~'J'~&lt;BR /&gt;
&lt;BR /&gt;
'~~~~~~~~~~~~~~~~~~~~~~'&lt;BR /&gt;
Option Explicit&lt;BR /&gt;
&lt;BR /&gt;
Function stringToDblArray(expStr As String)&lt;BR /&gt;
Dim i As Integer&lt;BR /&gt;
Dim VarPoints&lt;BR /&gt;
VarPoints = VBA.Split(expStr, ",")&lt;BR /&gt;
&lt;BR /&gt;
Dim check As Boolean&lt;BR /&gt;
check = False&lt;BR /&gt;
For i = 0 To UBound(VarPoints)&lt;BR /&gt;
If IsNumeric(VarPoints(i)) Then&lt;BR /&gt;
check = True&lt;BR /&gt;
End If&lt;BR /&gt;
Next&lt;BR /&gt;
&lt;BR /&gt;
If check = True Then&lt;BR /&gt;
ReDim fstAr(UBound(VarPoints)) As Double&lt;BR /&gt;
&lt;BR /&gt;
For i = 0 To UBound(VarPoints)&lt;BR /&gt;
fstAr(i) = CDbl(VarPoints(i))&lt;BR /&gt;
Next i&lt;BR /&gt;
stringToDblArray = fstAr&lt;BR /&gt;
Else&lt;BR /&gt;
ReDim SndAr(UBound(VarPoints)) As String&lt;BR /&gt;
For i = 0 To UBound(VarPoints)&lt;BR /&gt;
SndAr(i) = CStr(VarPoints(i))&lt;BR /&gt;
Next i&lt;BR /&gt;
stringToDblArray = SndAr&lt;BR /&gt;
End If&lt;BR /&gt;
&lt;BR /&gt;
End Function&lt;BR /&gt;
Sub test()&lt;BR /&gt;
Dim a As String, b As String, c, d&lt;BR /&gt;
&lt;BR /&gt;
a = "1,2,3,4,5"&lt;BR /&gt;
&lt;BR /&gt;
b = "a,b,c,d,e"&lt;BR /&gt;
&lt;BR /&gt;
c = stringToDblArray(a)&lt;BR /&gt;
&lt;BR /&gt;
d = stringToDblArray(b)&lt;BR /&gt;
&lt;BR /&gt;
If VarType(c) = vbArray + vbDouble Then&lt;BR /&gt;
MsgBox "First Returned Array Is An Array of Doubles"&lt;BR /&gt;
End If&lt;BR /&gt;
If VarType(d) = vbArray + vbString Then&lt;BR /&gt;
MsgBox "Second Returned Array Is An Array of Strings"&lt;BR /&gt;
End If&lt;BR /&gt;
End Sub</description>
      <pubDate>Tue, 05 Dec 2006 19:05:24 GMT</pubDate>
      <guid>https://forums.autodesk.com/t5/vba-forum/quick-array-question/m-p/1833842#M29519</guid>
      <dc:creator>Anonymous</dc:creator>
      <dc:date>2006-12-05T19:05:24Z</dc:date>
    </item>
  </channel>
</rss>

