Advertisement
Guest User

Untitled

a guest
Jun 24th, 2017
53
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
VB.NET 0.75 KB | None | 0 0
  1.     Private Sub ReplaceText(ByVal FileName As String, ByVal StartStr As String, ByVal ReplaceWith As String)
  2.         Dim l As String = ""
  3.         Dim full As String = ""
  4.         If IO.File.Exists(FileName) Then
  5.             Using sRead As New IO.StreamReader(FileName)
  6.                 While Not sRead.EndOfStream
  7.                     l = sRead.ReadLine
  8.                     If l.Trim.ToLower.Contains(StartStr.Trim.ToLower) Then
  9.                         l = l.Replace(l, ReplaceWith)
  10.                     End If
  11.  
  12.                     full &= l & vbNewLine
  13.                 End While
  14.             End Using
  15.  
  16.             Using sWrite As New IO.StreamWriter(FileName, False)
  17.                 sWrite.Write(full)
  18.             End Using
  19.         End If
  20.     End Sub
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement