Message 1 of 5
Quick Array Question
Not applicable
12-05-2006
07:29 AM
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report
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?
IF varpoints = "Double,Array"
Function stringToDblArray(VarPoints)
Dim StrAr() As Variant
VarPoints = VBA.Split(VarPoints, ",")
If IsNumeric(VarPoints) Then
ReDim ptaRr(UBound(VarPoints)) As Double
Dim i As Integer
For i = 0 To UBound(VarPoints)
ptaRr(i) = CDbl(VarPoints(i))
Next i
Else
ReDim StrAr(UBound(VarPoints)) As Variant
For i = 0 To UBound(VarPoints)
StrAr(i) = CStr(VarPoints(i))
Next i
End If
stringToDblArray = ptaRr
End Function
IF varpoints = "Double,Array"
Function stringToDblArray(VarPoints)
Dim StrAr() As Variant
VarPoints = VBA.Split(VarPoints, ",")
If IsNumeric(VarPoints) Then
ReDim ptaRr(UBound(VarPoints)) As Double
Dim i As Integer
For i = 0 To UBound(VarPoints)
ptaRr(i) = CDbl(VarPoints(i))
Next i
Else
ReDim StrAr(UBound(VarPoints)) As Variant
For i = 0 To UBound(VarPoints)
StrAr(i) = CStr(VarPoints(i))
Next i
End If
stringToDblArray = ptaRr
End Function