Solved

find and replace

Posted on 1998-06-14
7
159 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
Free Tool: Subnet Calculator

The subnet calculator helps you design networks by taking an IP address and network mask and returning information such as network, broadcast address, and host range.

One of a set of tools we're offering as a way of saying thank you for being a part of the community.

 

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

Free Tool: SSL Checker

Scans your site and returns information about your SSL implementation and certificate. Helpful for debugging and validating your SSL configuration.

One of a set of tools we are providing to everyone as a way of saying thank you for being a part of the community.

Question has a verified solution.

If you are experiencing a similar issue, please ask a related question

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…
You can of course define an array to hold data that is of a particular type like an array of Strings to hold customer names or an array of Doubles to hold customer sales, but what do you do if you want to coordinate that data? This article describes…
Get people started with the process of using Access VBA to control Outlook using automation, Microsoft Access can control other applications. An example is the ability to programmatically talk to Microsoft Outlook. Using automation, an Access applic…
Get people started with the process of using Access VBA to control Excel using automation, Microsoft Access can control other applications. An example is the ability to programmatically talk to Excel. Using automation, an Access application can laun…

839 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