请教一下,为什么运行时总是提示text1(i).text没有定义啊,到底应该怎么修改啊
Option ExplicitDim iCount As Long
Dim arrStr() As String
Private Sub Form_Load()
ReDim arrStr(0 To 255, 0 To 20) As String
iCount = 0
End Sub
Private Sub Command1_Click()
If iCount > 255 Then
MsgBox "超过行数限制"
Exit Sub
End If
Dim i As Long
For i = 0 To 20
arrStr(iCount, i) = Text1(i).Text
Next i
iCount = iCount + 1
For i = 0 To 20
Text1(i).Text = ""
Next i
End Sub
Private Sub Command3_Click() '保存(不合格)
If iCount > 255 Then Exit Sub
Dim Ex As Object
Dim ExBook As Object
Dim ExSheet As Object
Set Ex = CreateObject("Excel.Application")
Set ExBook = Ex.Workbooks.Add
Set ExSheet = ExBook.Worksheets("Sheet1") '打开
ExSheet.Activate '激活工作表
Ex.Visible = True
ExSheet.Range("A1:U1").Value = Array("产品型号", "测试日期", "测试时间", "峰峰值", "均方根值", "频率", "周期", "上升时间", "下降时间", "正脉宽", "负脉宽", "正占空比", "负占空比", "最大值", "最小值", "平均值", "幅度", "顶端值", "底端值", "过冲", "预冲")
Dim i As Long
Dim j As Long
For i = 0 To iCount - 1
For j = 1 To 21
ExSheet.Cells(i + 2, j) = arrStr(i, j - 1)
Next j
Next i
On Error Resume Next
Ex.ActiveWorkbook.SaveAs ("H:\测试数据保存(不合格).xls")
Set ExSheet = Nothing
Set ExBook = Nothing
Ex.Quit
Set Ex = Nothing
End Sub