2012-02-06 169 views
1

我有一個問題,這個代碼在VBA,得到運行時錯誤91.VBA運行時錯誤91

Private ChkTemp(90) As Checkbox 

ChkTemp(0) = Temp1 
. 
. 
. 
ChkTemp(89) = Temp90 

我試圖設計時checkbox(Temp1)分配給我的新聲明checkbox(ChkTemp)

+0

哪種味道的VBA? Excel,Word,Access ...? – Fionnuala 2012-02-06 13:18:03

回答

3

您需要;

Private ChkTemp(90) As MSForms.CheckBox 

並指定必須使用set對象引用;

Set ChkTemp(0) = Temp1 

你也可以;

Private ChkTemp(1 To 90) As MSForms.CheckBox 
... 
Dim i As Long 
For i = 1 To UBound(ChkTemp) 
    Set ChkTemp(i) = Me.Controls("Temp" & i) 
Next