《vb读取文本文件的某一行》由会员分享,可在线阅读,更多相关《vb读取文本文件的某一行(1页珍藏版)》请在金锄头文库上搜索。
1、Function lines(txtpath As String, ByVal startline As Integer, linenum As Integer) As String 显示 txtpath 文件的从startline 行开始的 linenum 行的内容 lines = Dim filetxt As String, x As Variant, i As Integer filetxt = String(FileLen(txtpath), ) Open txtpath For Binary As 1 Get #1, , filetxt Close 1 x = Split(filet
2、xt, vbCrLf) msgbox ubound(x)+1 行数 If startline UBound(x) Then MsgBox 行溢出, 64, err!: Exit Function If startline = UBound(x) Then If startline + linenum = UBound(x) Then For i = startline To startline + linenum - 1 lines = lines & x(i) & Next Else For i = startline To UBound(x) lines = lines & x(i) & Next End If: End If End Function