Need help with Visual Basic - limited programming knowledge - Programmers Heaven

Howdy, Stranger!

It looks like you're new here. If you want to get involved, click one of these buttons!

Categories

Welcome to the new platform of Programmer's Heaven! We apologize for the inconvenience caused, if you visited us from a broken link of the previous version. The main reason to move to a new platform is to provide more effective and collaborative experience to you all. Please feel free to experience the new platform and use its exciting features. Contact us for any issue that you need to get clarified. We are more than happy to help you.

Need help with Visual Basic - limited programming knowledge

Alexs777Alexs777 Posts: 1Member
For my computing project I have to make a stock control system. Basically, stored in a .dat file are the stock descriptions and I have programmed it to be displayed in a list box with this code:

Private Sub btnDisplayProducts_Click(ByVal sender As System.Object, ByVal e As System.EventArgs) Handles btnDisplayProducts.Click
Dim Index As Integer
Dim OneProduct As ProductType 'one record
lstDisplayFile.Items.Clear()
FileOpen(1, FileName, OpenMode.Random, , , Len(OneProduct))
For Index = 1 To NumberOfRecords 'loop through all records in file
FileGet(1, OneProduct, Index) 'read one record. 3rd parameter not needed use the declared format to display one product in the list box
lstDisplayFile.Items.Add(String.Format(MyFormat, OneProduct.ProductId, OneProduct.Description, Format(OneProduct.Price, "currency"), OneProduct.QuantityInStock, OneProduct.Reorderlevel))
Next Index
FileClose(1)
End Sub

Private Sub DisplayOneProduct(ByVal Product As ProductType)
lblProdId.Text = Product.ProductId
lblDescription.Text = Product.Description
lblPrice.Text = Product.Price
lblQuantity.Text = Product.QuantityInStock
lblRecLevel.Text = Product.Reorderlevel
End Sub


Now - I want to be able to delete items from this list box by clicking on them and pressing my delete button. However, I have absolutely no idea how to do this. Any help would be greatly appreciated.
Sign In or Register to comment.