对于我在VBA中的项目,我需要有这样的自定义类型:
Public Type Gene
Name As String
Expression() As Double 'holds data points, is a vector
Norm_Expression() As Double 'Holds normalized data, is a vector
Min_Corr As Double
Min_Profile As Integer
End Type
但是我发现很难通过redim语句来改变内部数组的大小。
ReDim Data(n)
For i = 1 To n
ReDim Preserve Data.Expression(Max_Time_Point)
Next i
不起作用。也没有:
For i = 1 To n
ReDim Data(n).Expression(Max_Time_Point)Does not work. Neither does:
Next i
你可以帮忙吗?谢谢!
答案 0 :(得分:1)
几乎就是 - 你需要指出你想要处理的Data
成员:
For i = 1 To n
ReDim Preserve Data(i).Expression(Max_Time_Point)
Next i
执行此操作时请注意
ReDim Data(n)
它与ReDim Data(0 to n)
相同所以在你的循环中,如果从1开始,你会错过第一个元素。