Solved

find and replace

Posted on 1998-06-14
7
158 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
PRTG Network Monitor: Intuitive Network Monitoring

Network Monitoring is essential to ensure that computer systems and network devices are running. Use PRTG to monitor LANs, servers, websites, applications and devices, bandwidth, virtual environments, remote systems, IoT, and many more. PRTG is easy to set up & use.

 

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

Does Powershell have you tied up in knots?

Managing Active Directory does not always have to be complicated.  If you are spending more time trying instead of doing, then it's time to look at something else. For nearly 20 years, AD admins around the world have used one tool for day-to-day AD management: Hyena. Discover why

Question has a verified solution.

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

The debugging module of the VB 6 IDE can be accessed by way of the Debug menu item. That menu item can normally be found in the IDE's main menu line as shown in this picture.   There is also a companion Debug Toolbar that looks like the followin…
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…
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 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…

778 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