VB.Net Save button not adding data to text file

I'm still new to VB.Net and have been stuck on this for a little over an hour. I'm trying to create an inventory management system where a form opens up for the user to enter pc specs and when I click save will save to the text file, so that it is read into the Inventory Tracker screen. Where each text box is disabled and appends the text as it is updated.

Currently nothing is happening, I've created the text file in the same directory as the project. Why is this?

I also tried putting a test message in the text file to display in the tracker text box, which is what will happen when I save the specs, however no message is appearing?

frmItemEntry.vb

Private Sub btnSave_Click(sender As Object, e As EventArgs) Handles btnSave.Click
Dim objMyStreamReader As System.IO.StreamReader
Dim objMyStreamWriter As System.IO.StreamWriter = System.IO.File.CreateText("inventory.txt")

Dim strInventory As String

objMyStreamWriter.WriteLine(txtManufacturerEntry)
objMyStreamWriter.WriteLine(txtProcessorEntry)
objMyStreamWriter.WriteLine(txtVideoEntry)
objMyStreamWriter.WriteLine(txtFormEntry)
objMyStreamWriter.WriteLine(txtRamEntry)
objMyStreamWriter.WriteLine(txtVramEntry)
objMyStreamWriter.WriteLine(txtHdEntry)
objMyStreamWriter.WriteLine(chkWirelessEntry)
objMyStreamWriter.Close()

Me.Close()

End Sub

frmTracker.vb

Private Sub txtManufacturer_TextChanged(sender As Object, e As EventArgs) Handles txtManufacturer.TextChanged
Dim streamReader As New System.IO.StreamReader(“inventory.txt”)
Dim strInventory As String
streamReader = System.IO.File.OpenText(“inventory.txt”)
strInventory = streamReader.ReadLine
txtManufacturer.AppendText(strInventory)
End Sub


#.net #vb.net

4 Likes2.05 GEEK