p2p.wrox.com Forums

Need to download code?

View our list of code downloads.


Go Back   p2p.wrox.com Forums > Visual Basic > VB.NET 1.0 > VB.NET 2002/2003 Basics
I forgot my password Register Now
Register | FAQ | Members List | Calendar | Search | Today's Posts | Mark Forums Read
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.

Reply
 
Thread Tools Search this Thread Display Modes
  #1 (permalink)  
Old March 16th, 2006, 07:48 PM
Registered User
 
Join Date: Mar 2006
Location: , , .
Posts: 2
Thanks: 0
Thanked 0 Times in 0 Posts
Default 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



Digg this Post!Add Post to del.icio.usBookmark Post in TechnoratiFurl this Post!Reddit!
Reply With Quote
  #2 (permalink)  
Old March 17th, 2006, 11:18 AM
Registered User
 
Join Date: Mar 2006
Location: , , .
Posts: 2
Thanks: 0
Thanked 0 Times in 0 Posts
Default

Fear not... I've cracked it! :)

Digg this Post!Add Post to del.icio.usBookmark Post in TechnoratiFurl this Post!Reddit!
Reply With Quote
  #3 (permalink)  
Old March 18th, 2006, 01:40 AM
Friend of Wrox
Points: 1,173, Level: 13
Points: 1,173, Level: 13 Points: 1,173, Level: 13 Points: 1,173, Level: 13
Activity: 0%
Activity: 0% Activity: 0% Activity: 0%
 
Join Date: Jun 2003
Location: , , .
Posts: 540
Thanks: 0
Thanked 0 Times in 0 Posts
Default

Please post your solution so that others can benefit. Thanks.
Digg this Post!Add Post to del.icio.usBookmark Post in TechnoratiFurl this Post!Reddit!
Reply With Quote
Reply


Thread Tools Search this Thread
Search this Thread:

Advanced Search
Display Modes

Posting Rules
You may not post new threads
You may not post replies
You may not post attachments
You may not edit your posts

vB code is On
Smilies are On
[IMG] code is Off
HTML code is Off
Trackbacks are Off
Pingbacks are On
Refbacks are Off
Forum Jump

Similar Threads
Thread Thread Starter Forum Replies Last Post
Find (also "find and replace") not working in Visu jayaraj123 Visual Web Developer 2005 4 April 22nd, 2009 06:15 AM
Best approach to replace characters with strings lumbrigack XSLT 8 June 16th, 2008 01:38 PM
Replace newline characters thomasjacob XML 1 May 2nd, 2006 05:06 AM
Find and replace? Stuart Stalker SQL Server 2000 8 October 13th, 2005 03:49 AM
Create a find and a find and replace in VB.NET snowy0 VB How-To 0 January 26th, 2004 07:03 PM



All times are GMT -4. The time now is 08:38 PM.


Powered by vBulletin® Version 3.6.8
Copyright ©2000 - 2009, Jelsoft Enterprises Ltd.
© 2008 Wiley Publishing, Inc