Solved

find and replace

Posted on 1998-06-14
7
160 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
[X]
Welcome to Experts Exchange

Add your voice to the tech community where 5M+ people just like you are talking about what matters.

  • Help others & share knowledge
  • Earn cash & points
  • Learn & ask questions
  • 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
Salesforce Made Easy to Use

On-screen guidance at the moment of need enables you & your employees to focus on the core, you can now boost your adoption rates swiftly and simply with one easy tool.

 

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

Industry Leaders: We Want Your Opinion!

We value your feedback.

Take our survey and automatically be enter to win anyone of the following:
Yeti Cooler, Amazon eGift Card, and Movie eGift Card!

Question has a verified solution.

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

Suggested Solutions

Title # Comments Views Activity
How does CurrentUser work? 10 42
using web browser with BING 40 136
Passing a Text Box name to a Sub 6 102
VB6 ListBox Question 4 57
Introduction I needed to skip over some file processing within a For...Next loop in some old production code and wished that VB (classic) had a statement that would drop down to the end of the current iteration, bypassing the statements that were c…
Introduction While answering a recent question (http://www.experts-exchange.com/Q_27402310.html) in the VB classic zone, I wrote some VB code in the (Office) VBA environment, rather than fire up my older PC.  I didn't post completely correct code o…
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…
This lesson covers basic error handling code in Microsoft Excel using VBA. This is the first lesson in a 3-part series that uses code to loop through an Excel spreadsheet in VBA and then fix errors, taking advantage of error handling code. This l…

730 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