Thread Rating:
  • 0 Vote(s) - 0 Average
  • 1
  • 2
  • 3
  • 4
  • 5
Read text from text file and save it into a variable in qtp
#1
Solved: 10 Years, 10 Months, 1 Week ago
Hi Guys,

I've a text file(data) which has 3 lines as following:

ABC
DEF
XYZ

I'm reading the text file using the following command:
Code:
Const ForReading = 1
Set fso = CreateObject("Scripting.FileSystemObject")
    s1="C:\temp\data.txt"
   Set theFile = fso.OpenTextFile(s1, ForReading, False)
   Do While theFile.AtEndOfLine <> True
      retstring = theFile.ReadLine
      msgbox retstring
      Loop
   theFile.Close

Now, i want to store the 3 values from text file into 3 variables in qtp.
For example,
V1=ABC
V2=DEF
V3=XYZ

Can somebody please help me out??
Reply
#2
Solved: 10 Years, 10 Months, 1 Week ago
i think instead of variables you can use Arrays.
Reply
#3
Solved: 10 Years, 10 Months, 1 Week ago
Split is the keyword you should be looking at. Then storing in variables would be easy.
Basanth
Give a fish to a man and you feed him for a day..Teach a man how to fish and you feed him for life.
Reply
#4
Solved: 10 Years, 10 Months, 1 Week ago
@ssvali : Thanks for your help.
@basanth27 : Thanks for your help.

I used Array and Split function and stored it in different variables. Again thanks ssvali and basanth27 for quick replies.
Reply


Possibly Related Threads…
Thread Author Replies Views Last Post
  Capture All text from webpage and copy it... mpatra 3 4,902 07-25-2018, 05:33 PM
Last Post: vimlesh
  LearnQuickTestPDF -does not work on just getting the text jloyzaga 0 1,179 02-10-2017, 10:59 AM
Last Post: jloyzaga
  How to edit a text in aParagraph shaan.mishra87@gmail.com 2 2,367 08-26-2016, 04:48 PM
Last Post: shaan.mishra87@gmail.com
  How to update CSV File and need to Save same CSV File kotaramamohana 1 3,321 10-24-2015, 08:40 AM
Last Post: tigerliew
  Not able to click the save button in Save As window while downloading from SAP kathirvelnagaraj 0 2,300 08-25-2015, 07:37 PM
Last Post: kathirvelnagaraj

Forum Jump:


Users browsing this thread: 1 Guest(s)