'On Error Resume Next
      Open (App.Path & "\1.txt") For Input As #1
          Do While Not EOF(1)
       
               Line Input #1, Intext
              Label1(i).Caption = Intext
              i = i + 1
                Loop
          Close #1
上面的是读取1.text文件。文件里每一行分的值配到Label1(i).Caption 数组的一个元素里
问,我不用数组,换成Label1.caption,Label2.caption,Label3.caption,……怎么分配写?

解决方案 »

  1.   

    'On Error Resume Next 
          Open (App.Path & "\1.txt") For Input As #1 
              Do While Not EOF(1) 
          
                  Line Input #1, Intext 
                  Label1& trim(i).Caption = Intext 
                  i = i + 1 
                    Loop 
              Close #1 
      

  2.   

    'On Error Resume Next 
          Open (App.Path & "\1.txt") For Input As #1 
              Do While Not EOF(1) 
          
                  Line Input #1, Intext 
                  Label & trim(i).Caption = Intext 
                  i = i + 1 
                    Loop 
              Close #1 
      

  3.   

    上面两个不行
    看看下面这个:'On Error Resume Next 
          Dim a()  As String
          ReDim a(150)'这个自己改
           i=0
          Open (App.Path & "\1.txt") For Input As #1 
              Do While Not EOF(1) 
          
                  Line Input #1, Intext
                  i = i + 1 
                  a(i) = "label" & Trim(i)
                  Me.Controls(a(i)).Caption = Intext
              Loop 
              Close #1 
              
      

  4.   

    Private Sub Form_Load()
    'On Error Resume Next
          Open (App.Path & "\1.txt") For Input As #1
              Do While Not EOF(1)
          
                  Line Input #1, Intext
                   i = i + 1
              For Each a In Me.Controls
              If TypeOf a Is Label Then
              If InStr(a.Caption, i) > 0 Then
              a.Caption = Intext
              End If
              End If
              Next
            Loop
              Close #1End Sub