I am attempting to efficiently (w/o looping) access all of the class variable values of a large-ish array of type customclass. The snippet below details what I want to do. Any suggestions are greatly appreciated. Thanks.
Public Class Coords
Public X As Double
Public Y As Double
Public Z As Double
End Class
Module Module2
Sub TestIt()
'Create and populate array of custom class
Dim CoordArray(1000) As Coords
Dim ubA As Short = UBound(CoordArray)
For p As Short = 0 To ubA
CoordArray(p).X = p
CoordArray(p).Y = 2 * p
CoordArray(p).Z = p ^ 2
Next p
'Attempt to create array containing all of
'the Y values without looping thru array
'None of these syntax attempts work
Dim YVals(ubA) As Double
YVals = CoordArray.Y
YVals = CoordArray{}.Y
YVals = CoordArray().Y
YVals = {CoordArray.Y}
'Any ideas or suggestions for how to
'efficiently do this (ie no looping)
'Any other tricks??
End Sub
End Module
Public Class Coords
Public X As Double
Public Y As Double
Public Z As Double
End Class
Module Module2
Sub TestIt()
'Create and populate array of custom class
Dim CoordArray(1000) As Coords
Dim ubA As Short = UBound(CoordArray)
For p As Short = 0 To ubA
CoordArray(p).X = p
CoordArray(p).Y = 2 * p
CoordArray(p).Z = p ^ 2
Next p
'Attempt to create array containing all of
'the Y values without looping thru array
'None of these syntax attempts work
Dim YVals(ubA) As Double
YVals = CoordArray.Y
YVals = CoordArray{}.Y
YVals = CoordArray().Y
YVals = {CoordArray.Y}
'Any ideas or suggestions for how to
'efficiently do this (ie no looping)
'Any other tricks??
End Sub
End Module