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!


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
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
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.