hello to all i am practicing creating a data file using streamwriter/reader. I am a beginner and what i am trying to do is create a data file and create a search button that will be able to search the data file and show in the listbox the item or items searched for.

this is my code. i tried also using FindExactString method but i just cant seem to be able to do it. i dont get how to use or write it correctly. any help would be appreciated thank you in advance.

Code:
Imports System.IO
Public Class Form1


    Private Sub Button1_Click(ByVal sender As System.Object, ByVal e As System.EventArgs) Handles Button1.Click
        Dim pInventory As IO.StreamWriter = IO.File.AppendText("product.txt")
        If TextBox1.Text = "" Or TextBox2.Text = "" Or TextBox3.Text = "" Then
            MsgBox("Please fill in required fields", MsgBoxStyle.Exclamation, "Error")
        Else
            pInventory.WriteLine(TextBox1.Text & ", $" & TextBox2.Text & ", " & TextBox3.Text)
            TextBox1.Clear()
            TextBox2.Clear()
            TextBox3.Clear()
            Dim num As Integer
            For num = 0 To ListBox1.Items.Count - 1
                pInventory.WriteLine(ListBox1.Items(num))
            Next
            pInventory.Close()
        End If
    End Sub
    Private Sub Button2_Click(ByVal sender As System.Object, ByVal e As System.EventArgs) Handles Button2.Click
      Dim name As String
        Dim num As Integer
        Dim max As Integer
name = InputBox("Enter a search word", "Search")
        num = 0
        max = ListBox1.Items.Count - 1
        'ListBox1.Items.Add(ListBox1.Items.Item(0))
        Do While (name <> (ListBox1.Items.Item(num))) And (num < max) **i keep getting an error in this line**
            num = num + 1

            ListBox1.Items.Add(num)
        Loop
        If (name = ListBox1.Items.Item(num)) Then
MsgBox(name & " Was found", , "Search")
        Else
MsgBox(name & " Was not found", , "Search")
        End If
end sub
end class