I'm a newbie to VB.Net. I created a listBox(lstInventory), 4 text boxes (txtDesc, txtRetailPrice,txtOnHand,txtQuantity)
and 4 label Boxes(lblSubTotal,lblSalesTax,lblGrandTotal). I just need ways to achieve this project.

Mainform on load reads inventory items from the file and updates the list box with error checking. Do not display items in the list box if OnHand is 0.

List box SelectedIndexChanged code:
When an item is selected in the list box, the description, retail price and units on hand boxes are
updated. The quantity is set to 1 by default and the subtotal, sales tax and grand total are empty.

Add to cart button code:
Checks to see if an item is selected in the list box and outputs an error if not.
Checks to see if the quantity is valid and outputs an error if it is not
Updates the subtotal, sales tax and grand total of purchase if quantity is valid

Complete purchase button code:
Checks to see if there is an item selected. If not, display an error message
If so, display a message box asking to confirm purchase of the item, quantity and total with yes no
buttons
If the user clicks Yes, reduce the quantity on hand and reset the form

Exit button or menu option closes the form 1
Mainform on close writes the updated information to the Inventory.txt file (as in Part 2) with error
checking

As always, have a go and post up your code when you get stuck. We like to help those that are willing to try and fail (thats how you learn)

yes It is homework but I was working through it. I need to learn how to do this. Here is my code so far and I'm having problems populating the textBoxes from the ListBox. Any suggestions why is not reading the InventoryNumber and to the Text boxes.

Imports System.IO


Public Class MainForm

    Const strFILENAME As String = "Inventory.txt"
    Public InvCollection As New List(Of Inventory)




    Private Sub MainForm_Load(sender As Object, e As EventArgs) Handles MyBase.Load
        Dim inventoryFile As System.IO.StreamReader
        Dim Inv As Inventory


        Try
            'Open .txt File
            inventoryFile = System.IO.File.OpenText("Inventory.txt")

            'Enter loop and read till end of .txt file.
            Do Until inventoryFile.Peek = -1

                'Assign Collection
                Inv = New Inventory

                'Read lines from .txt file, save into object properties.

                Inv.InventoryNumber = inventoryFile.ReadLine
                Inv.Description = inventoryFile.ReadLine
                Inv.PartCost = inventoryFile.ReadLine
                Inv.Retail = inventoryFile.ReadLine
                Inv.OnHand = inventoryFile.ReadLine

                'Assigns InventoryNumber to Listbox
                lstInventory.Items.Add(Inv.InventoryNumber)

                InvCollection.Add(Inv)

            Loop
            'Close the file.
            inventoryFile.Close()


        Catch Ex As Exception

            MessageBox.Show(Ex.Message)


        End Try

    End Sub



    Private Sub lstInventory_SelectedIndexChanged(sender As Object, e As EventArgs) Handles lstInventory.SelectedIndexChanged


        Dim SearchString As String = lstInventory.SelectedItems.ToString
        Dim InvItem As Inventory

        For Each InvItem In InvCollection
            If InvItem.InventoryNumber = SearchString Then
                InvItem.InventoryNumber = txtDesc.Text
                InvItem.Retail = txtRetail.Text
                InvItem.OnHand = txtOnHand.Text


            End If

        Next

    End Sub

End Class
This article has been dead for over six months. Start a new discussion instead.