VB如何读取文本 每行显示在label标签上  当读取到文本末尾是提示文本已结束 
  一个command  click事件就是跳到指定行  

解决方案 »

  1.   


       不要text   text背景色不能改透明    
      

  2.   

    放置一个label,一个command,C盘下面放一个包含内容的1.txt
    Option Explicit
    Dim strLine As StringPrivate Sub Command1_Click()
    Do While Not EOF(1)
    Line Input #1, strLine
    Label1.Caption = strLine
    Exit Do
    Loop
    If EOF(1) Then
        Label1.Caption = "文章结束!"
        Command1.Enabled = False
    End If
    End SubPrivate Sub Form_Load()
    Label1.AutoSize = True
    Command1.Enabled = False
    Open "c:\1.txt" For Input As #1
    Do While Not EOF(1)
    Line Input #1, strLine
    Label1.Caption = strLine
    Exit Do
    Loop
    Command1.Enabled = True
    End Sub
      

  3.   

    哦对了上面的
    If EOF(1) Then
        Label1.Caption = "文章结束!"
        Command1.Enabled = False
    End If
    修改为
    If EOF(1) Then
        Label1.Caption = "文章结束!"
        Command1.Enabled = False
        Close #1    '这儿应该在文章结束时,关闭打开的文件
    End If
      

  4.   


    label显示多行  可不可以  比如说是 现在显示5行  点击command1 之后显示后五行
      

  5.   

    用控件数组:
    Option ExplicitPrivate Sub Command1_Click()
      Dim strLine As String
      Dim i As Integer
      For i = 0 To 4
        If EOF(1) Then
          Label1(i).Caption = "文章结束!"
          Command1.Enabled = False
          Close #1
          Exit Sub
        End If
        Line Input #1, strLine
        Label1(i).Caption = strLine
      Next i
    End SubPrivate Sub Form_Load()
      Dim i As Integer
      for i = 0 To 4
        Label1(i).AutoSize = True
      Next i
      Open "c:\1.txt" For Input As #1
      Command1_Click
    End Sub
      

  6.   

    Option Explicit
    Private Sub Command1_Click()
      Dim strLine As String   '定义变量
      Dim i As Integer        '定义变量
      For i = 0 To 4
        If EOF(1) Then        '如果到最后一行  则
          Label1(i).Caption = "文章结束!"     'label1的名称显示文章结束
          Command1.Enabled = False        'command1的可见性为假
          Close #1                        '关闭文件
          Exit Sub
        End If
        Line Input #1, strLine                '读取每行赋值给变量strline
        Label1(i).Caption = strLine           'label数组的显示文字为strline
      Next i
    End SubPrivate Sub Form_Load()
      Dim i As Integer
      For i = 0 To 4
        Label1(i).AutoSize = True
      Next i
      Open "c:\1.txt" For Input As #1
      Command1_Click               '这句什么意思
    End Sub  为什么这里要有一个click  新手   麻烦讲解一下 谢谢指点
      

  7.   


    调用command1的click过程.
    比如说一个登陆界面,我在用户名文本框和密码文本框输入完用户名和密码之后,点击登陆按钮command1,就可以登陆.
    但是我想输入完用户名和密码后,直接在密码文本框直接回车也能实现登陆的效果,就可以调用command1_click这个过程.就不用复写登陆代码了.