I finally fixed my code and all that's left for me to do is to create a search button. what I'm trying to create is a search button but i just cant figure it out and i need help doing it. I am a beginner. I just want the program to ask the user what he would like to search for, when the search button is clicked on. when the user types in the word he wants to search for.....i want the program to look in the text file to see if that word exists and if the word exists i want that word to appear in my listbox. The problem with this is that i have nothing to work off of (everything I have written here is from previous homework assignments that I had to mess around with to get them to work.) This program has no purpose, this is just practice for me and if you could be able to help me i would be extremely grateful. If not thank you for taking the time to look at my post. Here is my code so far, if you see anything wrong with what i have written so far feel free to give me some advice to make it better. Thank you. (I have not created a search button):
Code:
Imports System.IO
    Public Class Form1
    
        Private Sub Form1_Load(ByVal sender As System.Object, ByVal e As System.EventArgs) Handles MyBase.Load
    
        End Sub
    
    
    
        Private Sub Button1_Click(ByVal sender As System.Object, ByVal e As System.EventArgs) Handles Button1.Click
    
    
            Dim archive As StreamWriter = New StreamWriter("stuff.txt", True)
    
            ListBox1.Items.Add(TextBox1.Text)
            ListBox1.SelectedIndex = ListBox1.SelectedIndex + 1
            archive.WriteLine(TextBox1.Text)
            archive.Close()
            MsgBox("ok")
    
        End Sub
    
        Private Sub Button2_Click(ByVal sender As System.Object, ByVal e As System.EventArgs) Handles Button2.Click
    
            Dim archive As StreamReader = New StreamReader("stuff.txt", True)
            ListBox1.Items.Clear()
            While archive.Peek() > -1
                ListBox1.Items.Add(archive.ReadLine)
            End While
            archive.Close()
        End Sub
    
    
        Public Sub DeleteLine(ByRef fileaddress As String, ByRef listbox1_selecteditem As String)
            Dim thefilelines As New List(Of String)
            thefilelines.AddRange(File.ReadAllLines(fileaddress))
            thefilelines.Remove(listbox1_selecteditem)
            File.WriteAllLines(fileaddress, thefilelines.ToArray)
    
        End Sub
    
    
        Private Sub Button3_Click(ByVal sender As System.Object, ByVal e As System.EventArgs) Handles Button3.Click
            DeleteLine("product.txt", ListBox1.SelectedItem)
            ListBox1.Items.Remove(ListBox1.SelectedItem)
    
            MsgBox("Item Deleted")
    
        End Sub
    
    End Class