Imports System.IO Public Class Form1 Dim start As Integer = 0 Dim replacements As New Dictionary(Of String, List(Of String)) Dim parts() As String Dim nextCheckIndex As Integer = 0 Private Sub Form1_Load(sender As Object, e As EventArgs) Handles MyBase.Load Using reader As New StreamReader("C:\Users\Acer\Desktop\Text Files1\output18.txt") Do Until reader.EndOfStream parts = reader.ReadLine().Split("|"c) If replacements.ContainsKey(parts(0)) Then replacements(parts(0)).Add(parts(1)) Else Dim newWordList As New List(Of String) newWordList.Add(parts(1)) replacements.Add(parts(0), newWordList) End If Loop End Using RichTextBox1.Text = "You gave a bad advice, irregardless of your intention. You provided a bad advice, irregardless of your intention. " End Sub Private Sub btnFind_Click(ByVal sender As System.Object, ByVal e As System.EventArgs) Handles btnFind.Click Dim startindex As Integer = 0 If RichTextBox1.Text.Length > 0 Then startindex = FindMyText(textBox1.Text.Trim, start, RichTextBox1.Text.Length) End If ' If string was found in the RichTextBox, highlight it If startindex >= 0 Then ' Set the highlight color as red RichTextBox1.SelectionColor = Color.Red ' Find the end index. End Index = number of characters in textbox Dim endindex As Integer = textBox1.Text.Length ' Highlight the search string RichTextBox1.Select(startindex, endindex) ' mark the start position after the position of ' last search string start = startindex + endindex End If End Sub Private Sub RichTextBox1_TextChanged(ByVal sender As System.Object, ByVal e As System.EventArgs) Handles RichTextBox1.TextChanged End Sub Private Sub BtnClose_Click(sender As System.Object, e As System.EventArgs) Handles BtnClose.Click Me.Close() End Sub Private Sub BtnDelete_Click(sender As System.Object, e As System.EventArgs) Handles BtnDelete.Click textBox1.Clear() End Sub End Class
var
This content, along with any associated source code and files, is licensed under The Code Project Open License (CPOL)