Is there an easy way to change the data type of an array without looping over it? For example suppose I read in a csv file with a bunch of numerical values and then turn that into an Array via Split(), now I have an array of Variant/String; but suppose I wanted an array of Variant/Double, how would I do that efficiently(without looping)?
so in my example below, I'd like to get arr2 from strTest without looping.
Sub test()
Dim arr1 As Variant, arr2 As Variant, strTest As String, i As Long
strTest = "1,2,3"
arr1 = Split(strTest, ",")
ReDim arr2(LBound(arr1) To UBound(arr1))
For i = LBound(arr1) To UBound(arr1)
arr2(i) = CDbl(arr1(i))
Next i
End Sub
thanks in advance.
Taylour
so in my example below, I'd like to get arr2 from strTest without looping.
Sub test()
Dim arr1 As Variant, arr2 As Variant, strTest As String, i As Long
strTest = "1,2,3"
arr1 = Split(strTest, ",")
ReDim arr2(LBound(arr1) To UBound(arr1))
For i = LBound(arr1) To UBound(arr1)
arr2(i) = CDbl(arr1(i))
Next i
End Sub
thanks in advance.
Taylour