I have a bar cash register and have buttons for the drinks and number pad. In the program I have it working and it is reading the File and storing it in a Array. the problem i have is writing back to the part of the textfile. Here is 2 of the drinks buttons, all the rest of the drinks are the same.
Could you tell Me Where I am going Wrong.

Public Structure Pints
        Dim Name As String
        Dim Price As Double
        Dim Quantity As Integer
        Dim QuantitySold As Integer
    End Structure

    Public products(41) As Pints

Private Sub frmEPOS_Load(ByVal sender As System.Object, ByVal e As System.EventArgs) Handles MyBase.Load
        Dim sr As IO.StreamReader = IO.File.OpenText("Drinks.txt")

        For counter As Integer = 0 To 41
            products(counter).Name = sr.ReadLine
            products(counter).Price = sr.ReadLine
            products(counter).Quantity = sr.ReadLine
            products(counter).QuantitySold = sr.ReadLine
        Next
        sr.Close()
    End Sub

 Private Sub btnOne_Click(ByVal sender As System.Object, ByVal e As System.EventArgs) Handles btnOne.Click
        intQuantity = 0


        intQuantity += 1
        decTotalDrinkPrice = intQuantity * decDrinkPrice
        lstItemsDisplayPanel.Items.Add(intQuantity & "  " & strDrinkName & " " & FormatCurrency(decTotalDrinkPrice))
        intStock -= intQuantity
        intQuantitySales += intQuantity
        decSubtotal += decTotalDrinkPrice

        Dim sw As IO.StreamWriter = IO.File.CreateText("Drinks.txt")


        sw.WriteLine(strDrinkName)
        sw.WriteLine(decDrinkPrice)
        sw.WriteLine(intStock)
        sw.WriteLine(intQuantitySales)


        sw.Close()

        decTotalDrinkPrice = 0
        decDrinkPrice = 0
        strDrinkName = ""

        btnOne.Enabled = False
        btnTwo.Enabled = False
        btnThree.Enabled = False
        btnFour.Enabled = False
        btnFive.Enabled = False
        btnSix.Enabled = False
        btnSeven.Enabled = False
        btnEight.Enabled = False
        btnNine.Enabled = False
        btnZero.Enabled = False


    Private Sub btnGuinness_Click(ByVal sender As System.Object, ByVal e As System.EventArgs) Handles btnGuinness.Click
        intQuantity = 0


        strDrinkName = products(0).Name
        decDrinkPrice = products(0).Price
        intStock = products(0).Quantity
        intQuantitySales = products(0).QuantitySold


        btnOne.Enabled = True
        btnTwo.Enabled = True
        btnThree.Enabled = True
        btnFour.Enabled = True
        btnFive.Enabled = True
        btnSix.Enabled = True
        btnSeven.Enabled = True
        btnEight.Enabled = True
        btnNine.Enabled = True
        btnZero.Enabled = True

    End Sub

    'Half Guinness Stout
    Private Sub btnHalfGuinness_Click(ByVal sender As System.Object, ByVal e As System.EventArgs) Handles btnHalfGuinness.Click
        intQuantity = 0

        strDrinkName = products(1).Name
        decDrinkPrice = products(1).Price
        intStock = products(1).Quantity
        intQuantitySales = products(1).QuantitySold


        btnOne.Enabled = True
        btnTwo.Enabled = True
        btnThree.Enabled = True
        btnFour.Enabled = True
        btnFive.Enabled = True
        btnSix.Enabled = True
        btnSeven.Enabled = True
        btnEight.Enabled = True
        btnNine.Enabled = True
        btnZero.Enabled = True

    End Sub

What exactly are you trying to do?
.Load file, modify certain lines, and save file back?

Be a part of the DaniWeb community

We're a friendly, industry-focused community of developers, IT pros, digital marketers, and technology enthusiasts meeting, networking, learning, and sharing knowledge.