I want to open a text file and then search some specified
text in it and then replace that text with some other text
i found that text in .txt but do not know how to replace
that text can any body help me. if possible put the code
for qtp
Answers were Sorted based on User's Feedback
Answer / rico
Const ForReading = 1, ForWriting = 2
Dim fso, f
Set fso = CreateObject("Scripting.FileSystemObject")
Set f = fso.OpenTextFile("c:\working\replace.txt",
ForWriting, True)
f.Write "QTP QTP RFT QTP QTP RFT QTP QTP"
Set f = fso.OpenTextFile("c:\working\replace.txt",
ForReading)
ReadAllTextFile = f.ReadAll
newText = Replace( ReadAllTextFile, "QTP", "QTPRO")
Set textFile = fso.OpenTextFile
( "C:\working\replace.txt", ForWriting )
textFile.WriteLine newText
f.Close
Is This Answer Correct ? | 12 Yes | 4 No |
Answer / venki
Function Replacestring(filepath,find_string,replace_string)
Const ForReading = 1
Const ForWriting = 2
Dim obj,notepad,myline,newText
Set obj = CreateObject("scripting.FileSystemObject")
Set notepad=obj.OpenTextFile(filepath,ForReading)
Do Until notepad.AtEndOfStream
myline = notepad.readall
loop
msgbox myline
newText = Replace(myline ,find_string,replace_string)
Set notepad = obj.openTextFile(filepath, ForWriting )
notepad.WriteLine newText
notepad.Close
msgbox newText
end function
Call Replacestring("C:\New Folder\fade to
black.txt","me","you")'>mention your file path,string to
find,replacing string.
Is This Answer Correct ? | 7 Yes | 2 No |
in one page we have 100 links i have to click the 99th link how can i click the 99th link.
4 Answers GK Technologies, IBM,
How can you handle exceptions in qtp?
What is the exact difference between QTP and RFT ?
How u call functions in QTP
Hi, How to give drop down values as input [Variable] from data table in QTP? If u know share with me.
I have application it is one digital clock with all minutes and seconds. you have to identify the time to verify weather the time displayed is correct time or not? How do you automate this scenario?
write a script for allinterview-submit Question first we've to select Choose Category,second select Sub- Category(Which is comes in to runtime)third select Question Type.for that give some descriptive and vb script
What is the use of low level recording? How does it useful?
What is the difference between Mandatory and BaseFilter Properies..Anybody please answer me..Thanks in Advance
How does Parameterization and Data-Driving relate to each other in QTP?
What is a Web Table?
How can we do Data driven testing Using For loop in QTP?