Imports System.IO
Public Class Form1
'This is where you rename a RichTextBox and give it a location'
Private rtb As New RichTextBox With {.Location = New Point(20, 20), .Dock = DockStyle.Fill}
'Here you create a textbox and rename is as tb'
Private WithEvents tb As New TextBox With {.BorderStyle = BorderStyle.None}
'This the AutoCompleteList is the new list for the function AutoCompleteStringCollection'
Private AutoCompleteList As New AutoCompleteStringCollection
'This one here is for the Replacement List'
Private ReplacementList As New Dictionary(Of String, String)
Private SelStart As Integer
Private Sub Form1_Load(sender As System.Object, e As System.EventArgs) Handles MyBase.Load
'This is where you declare the width of the form and location'
Width = 900
CenterToScreen()
'Here is adding the TextBox into the RichTextBox which is Called tb'
Controls.AddRange(New Control() {rtb, tb})
'This I think is where to start counting in order to tell the textbox that, that is a line'
For count As Integer = 1 To 10000
AutoCompleteList.Add("Line " & count.ToString)
Next
Dim inputFile As String = "C:\Users\Acer\Desktop\out.txt"
If File.Exists(inputFile) Then
Using sr As New StreamReader(inputFile)
While Not sr.EndOfStream
Dim wordParts = sr.ReadLine()
If wordParts.Count >= 1 Then
AutoCompleteList.Add(wordParts.ToString)
End If
End While
End Using
End If
tb.AutoCompleteCustomSource = AutoCompleteList
tb.AutoCompleteMode = AutoCompleteMode.Suggest
tb.AutoCompleteSource = AutoCompleteSource.CustomSource
rtb.Controls.Add(tb)
tb.Location = New Point(0, 0)
tb.Select()
End Sub
Private Sub tb_TextChanged(sender As Object, e As System.EventArgs) Handles tb.TextChanged
Dim Txt As String
If Not String.IsNullOrEmpty(tb.Text) Then
If tb.Text.EndsWith(" ") Then
If ReplacementList.ContainsKey(tb.Text.TrimEnd) Then
Txt = ReplacementList(tb.Text.TrimEnd)
Else
Txt = tb.Text
End If
rtb.SelectedText = Txt & " "
SelStart = rtb.TextLength
tb.Location = rtb.GetPositionFromCharIndex(rtb.TextLength)
tb.Text = ""
End If
End If
End Sub
End Class