Solved

find and replace

Posted on 1998-06-14
7
156 Views
Last Modified: 2010-05-03
Hello,

I need to open an html file and then do 'find and replace'. Can anyone tell me how I can do this?

Thanks.
0
Comment
Question by:DMM
  • 4
  • 3
7 Comments
 
LVL 1

Accepted Solution

by:
MAVERICK earned 100 total points
ID: 1463281
If you look through the PAQ's......  there is a text search item. Use the search to find the position and then try the following. BTW I think this example only works with a RTF box (Go to the components menu ....in project.) which is better for complex text like HTML

Assuming the search has the text selected, and you want to replace the search word with "Bill" and the RTF box is RTF1.
use this line
RTF1.seltext="Bill"


The following is from a PAQ for a text search
 This example uses the InStr function to return the position of the first occurrence of
   one string within another.

   SearchString ="XXpXXpXXPXXP" ' String to search in.
   SearchChar = "P" ' Search for "P".

   ' A textual comparison starting at position 4. Returns 6.
   MyPos = InStr(4, SearchString, SearchChar, 1)

   ' A binary comparison starting at position 1. Returns 9.
   MyPos = InStr(1, SearchString, SearchChar, 0)

   ' Comparison is binary by default (last argument is omitted).
   MyPos = InStr(SearchString, SearchChar) ' Returns 9.

   MyPos = InStr(1, SearchString, "W") ' Returns 0.



----------------------------------
BTW I'll see about finding a working example for you..... It is sometimes gets a better response If you give atleast 100 points for full working code! I'll try anyway

0
 

Author Comment

by:DMM
ID: 1463282
Adjusted points to 100
0
 

Author Comment

by:DMM
ID: 1463283
Maverick,

Thanks. I hope you can find a working example for me.

Regards
0
How to run any project with ease

Manage projects of all sizes how you want. Great for personal to-do lists, project milestones, team priorities and launch plans.
- Combine task lists, docs, spreadsheets, and chat in one
- View and edit from mobile/offline
- Cut down on emails

 

Author Comment

by:DMM
ID: 1463284
Hi Maverick,'

Did u have any luck with the sample code?

--DMM
0
 
LVL 1

Expert Comment

by:MAVERICK
ID: 1463285
not really ...... I think that the PAQ needs quite alot of work to get it going properl!
stay with it!

0
 
LVL 1

Expert Comment

by:MAVERICK
ID: 1463286
Hi DMM,
Command1 opens the Dialog Box
Command2 automatically searches and replaces the searchword in text1 with "zzzz"
So Richtextbox1 is the part which gets seached
Text1 is the search word
"zzzz" is the replace string!
If you didn't want to search Automatically you could insert a MsgBox to give you the choice!




Private Sub Command1_Click()
dlgCommonDialog.Filter = "All files(*.*)|*.*|HTML files (*.htm)|*.htm*"
 dlgCommonDialog.Action = 1
 RichTextBox1.filename = dlgCommonDialog.filename
     
     
End Sub

Private Sub Command2_Click()
Do
Mypos = 0
Mypos = InStr(Mypos + 1, RichTextBox1.Text, Text1.Text, 0)
If Mypos <> 0 Then
RichTextBox1.SelStart = Mypos - 1
RichTextBox1.SetFocus
RichTextBox1.SelLength = Len(Text1.Text)
RichTextBox1.SelText = "zzzz"
Else
MsgBox "Search String no found"
Exit Do
End If
Loop


 
End Sub

0
 

Author Comment

by:DMM
ID: 1463287
Hi Maverick,

Thanks. Sorry I didnt get back earlier. It works fine now.
0

Featured Post

Highfive Gives IT Their Time Back

Highfive is so simple that setting up every meeting room takes just minutes and every employee will be able to start or join a call from any room with ease. Never be called into a meeting just to get it started again. This is how video conferencing should work!

Join & Write a Comment

Introduction While answering a recent question about filtering a custom class collection, I realized that this could be accomplished with very little code by using the ScriptControl (SC) library.  This article will introduce you to the SC library a…
When designing a form there are several BorderStyles to choose from, all of which can be classified as either 'Fixed' or 'Sizable' and I'd guess that 'Fixed Single' or one of the other fixed types is the most popular choice. I assume it's the most p…
As developers, we are not limited to the functions provided by the VBA language. In addition, we can call the functions that are part of the Windows operating system. These functions are part of the Windows API (Application Programming Interface). U…
Get people started with the utilization of class modules. Class modules can be a powerful tool in Microsoft Access. They allow you to create self-contained objects that encapsulate functionality. They can easily hide the complexity of a process from…

760 members asked questions and received personalized solutions in the past 7 days.

Join the community of 500,000 technology professionals and ask your questions.

Join & Ask a Question

Need Help in Real-Time?

Connect with top rated Experts

19 Experts available now in Live!

Get 1:1 Help Now