前提,程序运行时MS2控件已经成功赋值,并且在选中不超过第6行的数据时,都能成功的吧数据传递给TEXT控件,但是当选在第7行以下的数据时,就在MS2.TextMatrix(r, 3)处提示下标越界
Private Sub MS2_DblClick()
'把选中行的数据传递给上方文本框
Dim r As Long
With Me.MS2
r = .MouseRow
If r >= .FixedRows And r < .Rows Then
Text2(1).Text = MS2.TextMatrix(r, 1) '型号
MsgBox Text2(2).Text ----------------------为了检测TEXT2(1).TEXT,这里还可以正常赋值
Text2(2).Text = MS2.TextMatrix(r, 3) '流量 -------------运行时这里提示错误
Text2(3).Text = MS2.TextMatrix(r, 4) '扬程
Text2(4).Text = MS2.TextMatrix(r, 5) '功率
ptdj1 = MS2.TextMatrix(r, 6) '转速
Text2(6).Text = MS2.TextMatrix(r, 7) '表价
End If
End With
End Sub
Private Sub MS2_DblClick()
'把选中行的数据传递给上方文本框
Dim r As Long
With Me.MS2
r = .MouseRow
If r >= .FixedRows And r < .Rows Then
Text2(1).Text = MS2.TextMatrix(r, 1) '型号
MsgBox Text2(2).Text ----------------------为了检测TEXT2(1).TEXT,这里还可以正常赋值
Text2(2).Text = MS2.TextMatrix(r, 3) '流量 -------------运行时这里提示错误
Text2(3).Text = MS2.TextMatrix(r, 4) '扬程
Text2(4).Text = MS2.TextMatrix(r, 5) '功率
ptdj1 = MS2.TextMatrix(r, 6) '转速
Text2(6).Text = MS2.TextMatrix(r, 7) '表价
End If
End With
End Sub