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
Answer Posted / 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 |
Post New Answer View All Answers
explain how to write vb script in qtp?when will you write own script?
When Recovery scenario actually starts while testing the application?
What is Test Fusion Report in QTP?
What are the ordinal identifiers in web page?
How to record application running on the Virtual machine?
Hello Everyone, Please provide me the practical example of business component concept of QTP.Like how to create business component,how to connect the quality center etc.... Thanks in advance, Gaytri
Step 3&4 are repeated until an the object in recognised uniquely.
Can any one send me the QTP Basic Coding Samples?
Describe the differences between functions and actions in UFT?
any body plz send health care domain project to me with explanation any two modules on that project. mail_id: ranjith_99reddy@yahoo.co.in
Explain building blocks of the bpt framework ?
What is 'sleep' in sync point?
Can UFT be connected to Quality Center? If ‘Yes’ brief the process or steps.
Differentiate the type of test cases which can be automated and which cannot be automated?
give me the code to save all messages of inbox of gmail into a folder and notepad