CodeGuru Home VC++ / MFC / C++ .NET / C# Visual Basic VB Forums Developer.com
Results 1 to 7 of 7
  1. #1
    Join Date
    Sep 2001
    Posts
    10

    removing characters from a string

    I am a VB novice so any help would be appreciated!

    I need to search through a string and replace any carriage returns, commas and line feeds with spaces. How can I do this?

    Thanks


  2. #2
    Join Date
    Jun 2001
    Location
    Sri Lanka
    Posts
    272

    Re: removing characters from a string

    get the help on following using MSDN & try it urself
    - Mid() , Instr() , Replace() , Chr() , Asc() ....

    If u don't know how to Rate an answer, then Rate my answer to learn, If u know, then practice it

  3. #3
    Join Date
    Jul 2000
    Location
    Milano, Italy
    Posts
    7,726

    Re: removing characters from a string

    Shrinka is right, but for a quick solution:
    mystring= replace(mystring,vbcrlf, "")
    mystring= replace(mystring,",", "")
    mystring= replace(mystring,chr(13) & " ", "")




    Special thanks to Lothar "the Great" Haensler, Tom Archer, Chris Eastwood, TCartwright, Bruno Paris, Dr_Michael
    and all the other wonderful people who made and make Codeguru a great place.
    Come back soon, you Gurus.

    The Rater
    ...at present time, using mainly Net 4.0, Vs 2010



    Special thanks to Lothar "the Great" Haensler, Chris Eastwood , dr_Michael, ClearCode, Iouri and
    all the other wonderful people who made and make Codeguru a great place.
    Come back soon, you Gurus.

  4. #4
    Join Date
    Jul 2000
    Location
    Milano, Italy
    Posts
    7,726

    Sorry!

    I mispelled your nickname. Sorry...

    Special thanks to Lothar "the Great" Haensler, Tom Archer, Chris Eastwood, TCartwright, Bruno Paris, Dr_Michael
    and all the other wonderful people who made and make Codeguru a great place.
    Come back soon, you Gurus.

    The Rater
    ...at present time, using mainly Net 4.0, Vs 2010



    Special thanks to Lothar "the Great" Haensler, Chris Eastwood , dr_Michael, ClearCode, Iouri and
    all the other wonderful people who made and make Codeguru a great place.
    Come back soon, you Gurus.

  5. #5
    Join Date
    Jul 2001
    Location
    Mumbai,India
    Posts
    382

    Re: removing characters from a string

    dim str as string
    str = "This is a s,tring with some tabs,commas
    and one carriage return"

    str = Replace(str,","," ")
    str = Replace(str,vbCrLf," ")
    str = Replace(str,vbTab," ")

    O/P :"This is a s tring with some tabs commas and one carriage return"





  6. #6
    Join Date
    Jul 2001
    Location
    Mumbai,India
    Posts
    382

    Re: removing characters from a string

    No longer!


  7. #7
    Join Date
    Jun 2001
    Location
    Sri Lanka
    Posts
    272

    Re: Sorry!

    with regard to mis-spell - that's alright!!!
    That's not my Nick Name but the Name

    i couldn't reply in detail as I was busy at that time
    Have a nice Day
    Srinika

    If u don't know how to Rate an answer, then Rate my answer to learn, If u know, then practice it

Posting Permissions

  • You may not post new threads
  • You may not post replies
  • You may not post attachments
  • You may not edit your posts
  •  





Click Here to Expand Forum to Full Width

Featured