错误:
代码:
MEPGene
基本上我创建类似于ListBox控件的东西(但能够根据我的喜好调整特定单元格,例如背景颜色,字体等),因此我的每一行都有多列。我在别处创建标签,然后我想将这些标签分配给每行保存它的数组。
给定索引,我想返回(Private pColumnLabels() As MSForms.Label
Public Property Get Column(Index As Integer) As MSForms.Label
'some irrelevant code here
Set Column = pColumnLabels(Index)
End Property
Public Property Set Column(lbl As MSForms.Label, Index As Integer) <--- errornous line
Set pColumnLabels(Index) = lbl
End Property
)该特定列的标签,例如Get
将返回给定列的标题。
为标签和索引提供row.Column(0).caption
该特定行的标签,例如:Set
。我可以看出为什么Set是错的,即。我应该做Set row.Column(0) = someLabel
这样的事情,但这在VBA中是不可能的。
有任何建议如何使这整洁?我知道我可以创建一个将传递参数的函数,例如:
Set row.Column = {someLabel, 0}
但是,我不能获得能够执行上面提供的示例的好功能,即代替:
Public Function passParams(lbl as MSForms.Label, Index as Integer)
Set pColumnLabels(Index) = lbl
End Function
我必须这样做
row.Column(0).caption 'get
Set row.Column(0) = someLabel 'set
答案 0 :(得分:1)
set to参数必须是最后一个,我开始工作了
Option Explicit
Private pColumnLabels() As MSForms.Label
Public Property Get columnx(i As Integer) As MSForms.Label
Set columnx = pColumnLabels(i)
End Property
Public Property Set columnx(i As Integer, lbl As MSForms.Label)
Set pColumnLabels(i) = lbl
End Property