Results 1 to 2 of 2

Thread: [2008] String replace in RTF file

  1. #1

    Thread Starter
    Addicted Member Alexandru_mbm's Avatar
    Join Date
    Jul 2007
    Location
    VBForums.com
    Posts
    157

    [2008] String replace in RTF file

    Can anyone tell me what's wrong with this code ??

    Code:
            Dim input As IO.StreamReader = New IO.StreamReader(Application.StartupPath & "\dcm.rtf")
            Dim output As IO.StreamWriter = New IO.StreamWriter(Application.StartupPath & "\dcm\" & denumire_folder_destinatie & "\" & denumire_fisier_destinatie)
            Dim buffer As String = input.ReadToEnd
    
            buffer = buffer.Replace("[filiala]", Me.txt_filiala.Text)
            buffer = buffer.Replace("[data]", Me.txt_data_cm.Text)
            buffer = buffer.Replace("[seriacm]", Me.txt_seria_cm.Text)
            buffer = buffer.Replace("[numarcm]", Me.txt_nr_cm.Text)
            buffer = buffer.Replace("[numeprenume]", Me.txt_nume_prenume.Text)
            buffer = buffer.Replace("[cnp]", Me.txt_cnp.Text)
            buffer = buffer.Replace("[scoalaabsolvita]", Me.txt_scoala_absolvita.Text)
            buffer = buffer.Replace("[serienrds1]", Me.txt_serie_nr_ds1.Text)
            buffer = buffer.Replace("[serienrds2]", Me.txt_serie_nr_ds2.Text)
            buffer = buffer.Replace("[serienrds3]", Me.txt_serie_nr_ds3.Text)
    
            output.Write(buffer)
            input.Close()
            output.Close()
    Is not replacing the stings and if i try tu change the strings for example "[filiala]" with "01filiala" etc... it's not replacing all of them!

    Why ? What's wrong ?
    I'm still learning VB.NET
    Sorry for my bad english
    Thanks for your help

  2. #2
    Hyperactive Member ProphetBeal's Avatar
    Join Date
    Aug 2006
    Location
    New York
    Posts
    424

    Re: [2008] String replace in RTF file

    At a quick glance your code looks correct however...what does your rtf file look like if you open it in a text editor like notepad? If you search for "[filiala]" in notepad, does it find anything?

    Helpful Links:
    VB 6 - How to get the "Key" Value in a collection
    VB.NET - File Search Utility || VB.NET - How to compare 2 directories || VB.NET - How to trust a network share
    VB.NET - Create Excel Spreadsheet From Array || VB.NET - Example Code & Hints you may not know
    VB.NET - Save JPEG with a certain quality (image compression) || VB.NET - DragDrop Files, Emails, and Email Attachments

    Please post some of the code you need help with (it makes it easier to help you)
    If your problem has been solved then please mark the thread [RESOLVED].
    Don't forget to Rate this post

    "Pinky, you give a whole new meaning to the phrase, 'counter-intelligence'."-The Brain-

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