Public Class Form1
Private Sub Button1_Click(sender As Object, e As EventArgs) Handles Button1.Click
Dim ofd As New OpenFileDialog
Dim strFile As String
With ofd
.Title = "Select a List"
.Filter = "Text Files|*.txt|All Files|*.*"
.ShowDialog()
strFile = .FileName
End With
If System.IO.File.Exists(strFile) = False Then Exit Sub
Dim Reader As New System.IO.StreamReader(strFile)
Dim strData As String
Dim i As Integer
Dim sp() As String
strData = Reader.ReadToEnd()
sp = strData.Split(vbCrLf)
For i = 0 To UBound(sp)
If sp(i).Length > 1 Then
If sp(i).Substring(1, 1) = "A" Then
If sp(i).Substring(sp(i).Length - 1, 1) = "0" Then
RichTextBox1.Text = RichTextBox1.Text & sp(i).Replace("0", "Replace with this")
End If
End If
End If
Next i
End Sub
End Class
I have this code but it doesn't seem to work,
i want it so it when it reads through all the file it finds all lines starting with "A" and ending with "0" to be replaced with given string then outputing all of the content from initial text file into richbox1 with the modified values