本帖最后由 bcrun 于 2011-11-20 12:16:14 编辑

解决方案 »

  1.   

    给你整理了下。Private Sub Cmdzhuaqu_Click()
    Dim a$, m%, n%, b$, c$, d$, a1$, a2$'检测txt文件内有多少条记录
      Open Txtlujing.Text For Input As #1
      m = 0
      While Not EOF(1)
      Input #1, a
      m = m + 1
      Wend
      Close #1  b = "0"
      Open Txtlujing.Text For Input As #1
      Dim strPath$, strFileName$, strTmp$
      For n = 1 To m
      Line Input #1, a
      Call trim(a$, a1$)
      If a1 <> b Then
        b = a1
        strPath = App.Path & "\" '当前目录
        strTmp = b & "01.Txt" '文件名称
        strFileName = strPath & strTmp '指定路径名称
        Open strFileName For Output As #2
        Print #2, a
        Close #2
      Else
        Open strFileName For Append As #2
        Print #2, a ' "这里写入文件内容"
        Close #2
      End If
       
    Next n
      Close #1
    End Sub
      

  2.   

    GoTo 10 以及if的for循环的嵌套注意检查一下。