Because you are Dimming the array as an array of 1 item with an index of 1. You need to give it the entire range you are using so,
Dim DataType(0 to 1) as Variant
Dim Data(0 to 1) as Variant
Bob, This actually is not quite right......If your Index base is 0, using Dim Data(1) as Whatever knows you mean Data(0 to 1).....here's a simple Example to demonstrate this:
Sub test()
Dim MyArray(2) As String
MyArray(0) = "Test1"
MyArray(1) = "Test2"
MyArray(2) = "Test3"
Dim i As Integer
For i = 0 To UBound(MyArray)
Debug.Print MyArray(i)
Next
End Sub
Now, I prefer the way you show so you know the Lower & Upper bounds, but it's not mandatory.
Tim,
The error you get regarding an Object is due to your using this format
Set Data(0) = Str1
Set Data(1) = Str2
Set DataType(0) = 1
Set DataType(1) = 2
You use Set ONLY when you are casting some type of object. In this case, strings and integers are not objects, so lose the Set..... another error will pop up though, as Autocad expects DXF codes to be Integers and the array must be dimensioned as such.....make sure to change the first Function/Sub to accept an Integer array, too.
So for anything that uses the DXF codes, such as Xrecords, SelectionSet filters, etc., you want to use this format:
Dim DataType(1) As Integer
Dim Data(1) As Variant
Data(0) = Str1
Data(1) = Str2
DataType(0) = 1
DataType(1) = 2
HTH