标题:请教一下,为什么运行时总是提示text1(i).text没有定义啊,到底应该怎么修改 ...
取消只看楼主
琥珀1988
Rank: 1
等 级:新手上路
帖 子:4
专家分:0
注 册:2012-11-13
结帖率:0
 问题点数:0 回复次数:0 
请教一下,为什么运行时总是提示text1(i).text没有定义啊,到底应该怎么修改啊
Option Explicit

Dim 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
搜索更多相关主题的帖子: Text1 
2012-11-14 20:06



参与讨论请移步原网站贴子:https://bbs.bccn.net/thread-387065-1-1.html




关于我们 | 广告合作 | 编程中国 | 清除Cookies | TOP | 手机版

编程中国 版权所有,并保留所有权利。
Powered by Discuz, Processed in 0.109942 second(s), 8 queries.
Copyright©2004-2025, BCCN.NET, All Rights Reserved