|
|
 |
| VB.NET 2002/2003 Basics For coders who are new to Visual Basic, working in .NET versions 2002 or 2003 (1.0 and 1.1). |
Welcome to the p2p.wrox.com Forums.
You are currently viewing the VB.NET 2002/2003 Basics section of the Wrox p2p Programmer to Programmer discussion community. This is a community of more than 40,000 computer programmers including Wrox book authors and readers. As a guest, you can read any forum posting. By joining our free Wrox p2p community you can post your own programming questions and respond to other programmers’ questions. Registered users also don't have to see the ads that are displayed to guests. Registration is fast, simple and absolutely free so please, join today!
Join today and post to win prizes! Post more to increase your chances of being Wrox’s top poster of the month.
|
 |

March 16th, 2006, 07:48 PM
|
|
Registered User
|
|
Join Date: Mar 2006
Location: , , .
Posts: 2
Thanks: 0
Thanked 0 Times in 0 Posts
|
|
Find and Replace 2 characters at once!! HELP
Hi All... my brain is going to pop. I am writing a small application that allows you to cut and paste text from anything into a text box and then have it re-formatted taking out certain CRs and replacing them with others.
If it were a simple find and replace that would be no problem, but, this is what I want to do:
I want to find all instances of chr(34) and chr(46) (. & ") at the same time and replace them with . " # at the same time - make sense? (the reason I want to add the # is because I am going to newline that afterwards)
How can I find two characters together and replace with 3?
If I replace them seperately they will replace all instances of '.' (for instance) throughout the whole string. I only want to replace when the two (.") are next to each other.
here is some code I have been playing with - but it doesn't work as such! I must be close - the pain in my head tells me so ;)
Any tips much appreciated... Sco
---------------------------------------
firstfind = Chr(46) + Chr(13)
RemoveCharacters(TextBox1.Text, firstfind) >>> calls
Public Function RemoveCharacters(ByRef strText As String, _
ByRef strUnwanted As Char) As String
Dim currLoc As Integer
Dim StringLength As Integer
Dim tmpChar As String
StringLength = Len(strText)
For currLoc = 1 To StringLength
tmpChar = Mid(strText, currLoc, 2)
If InStr(strUnwanted, tmpChar) Then
Mid(strText, currLoc, 3) = Chr(46) + Chr(34) + Chr(35)
End If
Next
RemoveCharacters = strText
End Function
|

March 17th, 2006, 11:18 AM
|
|
Registered User
|
|
Join Date: Mar 2006
Location: , , .
Posts: 2
Thanks: 0
Thanked 0 Times in 0 Posts
|
|
Fear not... I've cracked it! :)
|

March 18th, 2006, 01:40 AM
|
|
Friend of Wrox
|
|
Join Date: Jun 2003
Location: , , .
Posts: 540
Thanks: 0
Thanked 0 Times in 0 Posts
|
|
Please post your solution so that others can benefit. Thanks.
|
| Thread Tools |
Search this Thread |
|
|
|
| Display Modes |
Linear Mode
|
Posting Rules
|
You may not post new threads
You may not post replies
You may not post attachments
You may not edit your posts
HTML code is Off
|
|
|
|
 |