我正在尝试在Access VBA中设置一个阵列。我有40种不同的参数来设置和使用: 'ParameterName1.Visible = True ... 'ParameterName2.Visible = True ...
有点笨拙。我相信可以使用以下数组来实现:
'for i = 1至40 'ParameterName(i).Visible = True “下一个我
我是Access vba的新手。我已经做了一些简单的编码,但这是我第一次尝试数组
Private Sub Form_Load()
Dim NewPN As Boolean
Dim i As Integer
Dim ParameterName(1 To 10) As Variant
Dim ParameterNominal(1 To 10) As Variant
Dim ParameterMinimum(1 To 10) As Variant
Dim ParameterMaximum(1 To 10) As Variant
NewPN = MsgBox("Is This A New Part Number?", vbYesNo, "New Part Number")
If NewPN = True Then
For i = 1 To 10
ParameterName(i).Visible = False
ParameterNominal(i).Visible = False
ParameterMinimum(i).Visible = False
ParameterMaximum(i).Visible = False
Next i
ParaQty = InputBox("How many parameters will be measured?", Parameters?")
For i = 1 To ParaQty
ParameterName(i) = InputBox("Please Enter the Name for Parameter
(Include Units, if applicable) " & i, "Parameter Name?")
ParameterNominal(i) = InputBox("Please Enter the Nominal Value
for Parameter " & i, "Nominal Parameter?")
ParameterMinimum(i) = InputBox("Please Enter the Minimun Value for
Parameter " & i, "Minimum Parameter?")
ParameterMaximum(i) = InputBox("Please Enter the Maximum Value for
Parameter " & i, "Maximum Parameter?")
Next i
End If
结束子
在for / next循环的第一遍时,我收到一条“需要对象”错误消息。