Thread: Array problem
View Single Post
  #2 (permalink)  
Old 11-03-09, 12:53
Ax238 Ax238 is offline
Registered User
 
Join Date: May 2009
Posts: 257
Looks like you are putting a one-dimensional array into every index of a one-dimensional array, here:
Code:
myArray(cnt) = Array(xmlNode.Attributes(0).nodeValue, xmlNode.Attributes(1).nodeValue)
This is what you would call nested arrays. myArray is never more than a one-dimensional array. So in your example, myArray(0) contains a one-dimensional array with Array(0)="1Y SW" and Array(1)="1.25".

You should use the following for the Redim:
Code:
ReDim myArray(xmlNodeList.Length, 1) As Variant
This assumes that there will only be two attributes used from each node.

You would then use the following in the For loop:
Code:
myArray(cnt,0) = xmlNode.Attributes(0).nodeValue
myArray(cnt,1) = xmlNode.Attributes(1).nodeValue
Looks like your first dimension will be one more than the total number of elements in the array though, so you might want to use xmlNodeList.Length-1 instead.

Ax
Reply With Quote