Dim sRet
//sRet = File.Read('''C:\Users\huang\Desktop\搜索关键字.txt''',"utf-8")
Function file_readline(path,nline,sCharset='utf-8')
Try
Dim sText= File.Read(path,sCharset)
dim arrText = Split(sText,"\n")
Dim nLines = UBound(arrText)+1
if nline >nLines
Throw "超出文件最大行数"
Else
End if
Catch err
TracePrint("错误流程块:" & err["File"] &\
",错误信息:" & err["Line"] &\
",错误信息:" & err["Message"])
Else
Return arrText[nline-1]
//数组下标从0开始
End Try
End Function
TracePrint(file_readline("C:\\Users\\huang\\Desktop\\搜索关键字.txt",365))
UIbot学习笔记:通过分隔符拆解实现按行读取txt文件
最新推荐文章于 2022-02-11 10:07:20 发布