Solved

find and replace

Posted on 1998-06-14
7
157 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
Is Your Active Directory as Secure as You Think?

More than 75% of all records are compromised because of the loss or theft of a privileged credential. Experts have been exploring Active Directory infrastructure to identify key threats and establish best practices for keeping data safe. Attend this month’s webinar to learn more.

 

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

Is Your Active Directory as Secure as You Think?

More than 75% of all records are compromised because of the loss or theft of a privileged credential. Experts have been exploring Active Directory infrastructure to identify key threats and establish best practices for keeping data safe. Attend this month’s webinar to learn more.

Question has a verified solution.

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

Most everyone who has done any programming in VB6 knows that you can do something in code like Debug.Print MyVar and that when the program runs from the IDE, the value of MyVar will be displayed in the Immediate Window. Less well known is Debug.Asse…
If you need to start windows update installation remotely or as a scheduled task you will find this very helpful.
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…
Show developers how to use a criteria form to limit the data that appears on an Access report. It is a common requirement that users can specify the criteria for a report at runtime. The easiest way to accomplish this is using a criteria form that a…

910 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

23 Experts available now in Live!

Get 1:1 Help Now