Want to protect your cyber security and still get fast solutions? Ask a secure question today.Go Premium

x
?
Solved

Detect and replace in a String

Posted on 2003-03-05
4
Medium Priority
?
146 Views
Last Modified: 2010-05-01
looking for a bit of code that would find all of "Teh" and replace it with "The"
(and no i dont need a spell checker)
0
Comment
Question by:gthgb
  • 2
4 Comments
 
LVL 14

Expert Comment

by:jjardine
ID: 8071087
Replace(string,find,replacewith[,start[,count[,compare]]])

Ex.
YourString = Replace (YourString,"teh","the")
0
 
LVL 14

Expert Comment

by:aelatik
ID: 8071091
StringReplaced = Replace("The string to search in", "Teh", "The")
MsgBox StringReplaced
0
 
LVL 14

Accepted Solution

by:
aelatik earned 400 total points
ID: 8071128
OK, these method will cause problems with words containing
'Teh', use the following function to avoid that problem.


Private Sub Form_Load()
MsgBox CheckForThe("Teh word to split is here in Teheran")
End Sub
Function CheckForThe(StringToCheck As String)
    WordArray = Split(StringToCheck, " ")
        For Each Word In WordArray
            If Word = "Teh" Then Word = "The"
            Result = Result & Word & " "
            CheckForThe = Result
        Next
End Function

0
 

Author Comment

by:gthgb
ID: 8071161
overkill :) thanks
0

Featured Post

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.

Question has a verified solution.

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

Have you ever wanted to restrict the users input in a textbox to numbers, and while doing that make sure that they can't 'cheat' by pasting in non-numeric text? Of course you can do that with code you write yourself but it's tedious and error-prone …
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 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…
Suggested Courses
Course of the Month10 days, 22 hours left to enroll

571 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