Golgappa.net | Golgappa.org | BagIndia.net | BodyIndia.Com | CabIndia.net | CarsBikes.net | CarsBikes.org | CashIndia.net | ConsumerIndia.net | CookingIndia.net | DataIndia.net | DealIndia.net | EmailIndia.net | FirstTablet.com | FirstTourist.com | ForsaleIndia.net | IndiaBody.Com | IndiaCab.net | IndiaCash.net | IndiaModel.net | KidForum.net | OfficeIndia.net | PaysIndia.com | RestaurantIndia.net | RestaurantsIndia.net | SaleForum.net | SellForum.net | SoldIndia.com | StarIndia.net | TomatoCab.com | TomatoCabs.com | TownIndia.com
Interested to Buy Any Domain ? << Click Here >> for more details...

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


Please Help Members By Posting Answers For Below Questions

explain how to write vb script in qtp?when will you write own script?

2313


When Recovery scenario actually starts while testing the application?

2031


What is Test Fusion Report in QTP?

1174


What are the ordinal identifiers in web page?

1149


How to record application running on the Virtual machine?

1094


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

1874


Step 3&4 are repeated until an the object in recognised uniquely.

2033


Can any one send me the QTP Basic Coding Samples?

2087


Describe the differences between functions and actions in UFT?

1155


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

3889


Explain building blocks of the bpt framework ?

1117


What is 'sleep' in sync point?

1108


Can UFT be connected to Quality Center? If ‘Yes’ brief the process or steps.

1102


Differentiate the type of test cases which can be automated and which cannot be automated?

1036


give me the code to save all messages of inbox of gmail into a folder and notepad

2108