Read selected lines from a notepad file
There is no method to read required lines from a file but we can do the below approach
a. Read each line from file and store in array
b. Read from array based on index
Ex: data.txt
Testing Tools
QTP Automation
Software Testing
QTP and QC integration
VBScripting
For the above file QTP Script
Dim fs,f
ReDim a(0)
'''open the file for reading
Set fs=CreateObject("Scripting.FileSystemObject")
set f=fs.openTextFile("data.txt",1)
''''read each line and store in array
size=0
while f.atendofline<>True
a(size)=f.readline
size=size+1
ReDim Preserve a(size)
Wend
f.close
''''from array we can read the required lines
msgbox a(2)
msgbox a(4)
Comments
Post a Comment