Basically my program is a list of products with their barcodes and quantities. The user can search for an item, which is displayed in the listview, then edit it to add or reduce the quantity. When they click save it is written to the file. That is all working fine, but it is now showing the item twice, same barcode and product name and different quantities.
I tried to use the replace function but that is just adding empty lines of text to my file. I have also gotten advice to copy the file and remove the selected item. I'm unsure how to do this. Does anyone have any alternative ways to do this? Here is my code:
Private Sub cmdEdit_Click() Dim barcode As String Dim prodNum As String Dim unknown As String Dim desc As String Dim size As String Dim costPrice As String Dim retailPrice As String Dim deptCode As String Dim dept As String Dim subDeptCode As String Dim subDept As String Dim quantity As String Dim barcodeYes As String Dim Number As String Dim i As Single ListView1.ListItems.Remove ListView1.SelectedItem.Index Open "D:\VB\EXPORT PRODUCT FILE.CSV" For Input As #3 Input #3, barcode, prodNum, unknown, desc, size, costPrice, retailPrice, deptCode, dept, subDeptCode, subDept, quantity, barcodeYes, Number AddQuantity.Show AddQuantity.txtName.Text = ListView1.SelectedItem AddQuantity.txtBarcode.Text = ListView1.SelectedItem.SubItems(1) AddQuantity.txtQuantity.Text = ListView1.SelectedItem.SubItems(2) Close #3 End Sub