如上.

解决方案 »

  1.   

    一个字符一个字符的读取
    如果是chr(13)
    则行数+1
      

  2.   


    Private Declare Function SendMessage Lib "user32" Alias "SendMessageA" (ByVal hwnd As Long, _     ByVal wMsg As Long, _     ByVal wParam As Long, _     lParam As Any) As LongConst EM_GETLINECOUNT = &HBA Public Function LineCount(txtBox As TextBox) As Long     LineCount = SendMessage(txtBox.hwnd, EM_GETLINECOUNT, 0&, 0&)End Function
     Private Sub Command1_Click()    MsgBox LineCount(Text1)End Sub
      

  3.   

    把文件读入一个字符串,然后n = len(strFile) - len(replace(strFile, vbcrlf, "") + 1
      

  4.   

    n = len(strFile) - len(replace(strFile, vbcrlf, "")) + 1
      

  5.   

    up
    就是看看换行标志符号vbcrlf有多少个
      

  6.   

    dim strx as string
    dim hangshu as long'行数
    open "C:\txt1.txt" for input as 1
    hangshu = 0
    do until eof(1)
        line input #1,strx'依次读出一行
        hangshu = hangshu + 1
    loop
      

  7.   

    viena(晓琴)的方法比较常用但对大文件速度会很慢
      

  8.   

    line input #会识别行尾,需要注意的是,读入变量的strx,不包括回车换行,在这里strx是废弃没用的,如果要用的话,比如需要读入整个文件的内容,要手工加上回车换行:
    filecontext = filecontext & strx & chr(13) & chr(10)