Quantcast
Channel: how to replace a word in specific line in text file
Viewing all articles
Browse latest Browse all 5

how to replace a word in specific line in text file

$
0
0

Hi

I tried your code line.  I used a text file containing:

*

Here is some faux text with faux contained in the flow faux of characters where faux will be replaced faux with 'ok' as requested. faux

*

After running the text file contained:

*

Here is some ok text with ok contained in the flow ok of characters where ok will be replaced ok with 'ok' as requested. ok

*

So, what problems are you having. I can't help but think Iam misunderstanding your question. I realise that your written English is not your first language, but I think it is the cause of my misunderstanding.

*

You make a reference to 'numbers' - but which numbers, and what is their relevance?

*

Here is the code I tested with

Option Strict On
Option Explicit On
Public Class Form1
  Dim path As String = IO.Path.Combine(My.Computer.FileSystem.SpecialDirectories.Desktop, "Testing.txt")
  Private Sub Form1_Load(sender As Object, e As EventArgs) Handles MyBase.Load

    My.Computer.FileSystem.WriteAllText(TextBox1.Text, My.Computer.FileSystem.ReadAllText(TextBox1.Text).Replace("faux", "ok"), False)

  End Sub
End Class

This was starting contents of the Text file:

Here is some faux text with
faux contained in the flow faux
of characters where faux will
be replaced faux with 'ok' as
requested. faux

and the contents after running code

Here is some ok text with
ok contained in the flow ok
of characters where ok will
be replaced ok with 'ok' as
requested. ok


Regards Les, Livingston, Scotland



Viewing all articles
Browse latest Browse all 5

Trending Articles



<script src="https://jsc.adskeeper.com/r/s/rssing.com.1596347.js" async> </script>