vbScript 从特定行读取文件
vbScript read file from an specific line
大家好我有一个疑问,关于如何从特定行开始读取 .txt 文件,我得到了行号从我想开始阅读,我正在尝试阅读它,但总是从第一行开始
而且需要几分钟才能到达我需要的线路
这是我的代码
'Call F_CMN_GRL_FindObjects(17,15)
strProperty = F_CMN_GRL_GlobalMain(6,17,15,0,"all items" )
strLine = split(strProperty,",")
Print strLine(0)
strValor = split(strLine(0)," ")
Print strValue(1)
numberLine = strValue(1)
Call readFromLine(numberLine)
Function readFromLine(numberLine)
numberLineEnd =numberLine + 7
print numberLine
print numberLineEnd
' Option Explicit
Dim oFso : Set oFso = CreateObject("Scripting.FileSystemObject")
Dim oFile : Set oFile = oFso.OpenTextFile("C:\myFile.txt", 1)
' Dim myArray()
' ReDim myArray(0)
'numberLine it's the number line from I want to start to read and I want to read until numberLineEnd
For i = numberLine to numberLineEnd step 1
strLine = oFile.ReadLine
print strLine
Next
'i = i + 1
'numberLine = numberLine + 1
End Function
我是这样解决的:
Dim i
Do While (i <= numeroLineaFin)
If (i => numeroLinea) and (i<=numeroLineaFin) Then
' If i <= numeroLineaFin Then
' tmpstr = tmpstr & oFile.readline & VbCrLf
tmpstr = oFile.readline
print tmpstr
' else
' oFile.SkipLine
' End If
else
oFile.SkipLine
end if
i = i + 1
Loop
大家好我有一个疑问,关于如何从特定行开始读取 .txt 文件,我得到了行号从我想开始阅读,我正在尝试阅读它,但总是从第一行开始
而且需要几分钟才能到达我需要的线路
这是我的代码
'Call F_CMN_GRL_FindObjects(17,15)
strProperty = F_CMN_GRL_GlobalMain(6,17,15,0,"all items" )
strLine = split(strProperty,",")
Print strLine(0)
strValor = split(strLine(0)," ")
Print strValue(1)
numberLine = strValue(1)
Call readFromLine(numberLine)
Function readFromLine(numberLine)
numberLineEnd =numberLine + 7
print numberLine
print numberLineEnd
' Option Explicit
Dim oFso : Set oFso = CreateObject("Scripting.FileSystemObject")
Dim oFile : Set oFile = oFso.OpenTextFile("C:\myFile.txt", 1)
' Dim myArray()
' ReDim myArray(0)
'numberLine it's the number line from I want to start to read and I want to read until numberLineEnd
For i = numberLine to numberLineEnd step 1
strLine = oFile.ReadLine
print strLine
Next
'i = i + 1
'numberLine = numberLine + 1
End Function
我是这样解决的:
Dim i
Do While (i <= numeroLineaFin)
If (i => numeroLinea) and (i<=numeroLineaFin) Then
' If i <= numeroLineaFin Then
' tmpstr = tmpstr & oFile.readline & VbCrLf
tmpstr = oFile.readline
print tmpstr
' else
' oFile.SkipLine
' End If
else
oFile.SkipLine
end if
i = i + 1
Loop