I am making POS software for a company and i use a listview box to delete a item off the bill. The user selects the item in the listview box that they want to delete then clicks the delete item button and if it the quantity is greater then 1 then it removes one off the quantity if the quantity is equal to 1 then it gets removed from the bill.
The problem is if you have only one item in the bill and its quantity is 1 and you try to delete it my program crashes and I don’t know how to fix it.
The code is as follows
If Int(lstbill.ListItems(lstbill.SelectedItem.Index).SubItems(3)) = 1 Then
If Int(lstbill.ListItems(lstbill.SelectedItem.Index).SubItems(3)) > 1 Then
lstbill.ListItems(lstbill.SelectedItem.Index).SubItems(3) = lstbill.ListItems(lstbill.SelectedItem.Index).SubItems(3) - 1
bill(lstbill.SelectedItem.Index) = bill(lstbill.SelectedItem.Index) - 1
It crashes at If Int(lstbill.ListItems(lstbill.SelectedItem.Index).SubItems(3)) > 1 Then with the error "Object variable or With block variable not set"
I’ve seen a number of people looking for examples of how to access web services from VB6. I’ve been using a test harness I built in VB6 (using many resources I found online) that I use for small projects to work out how to communicate with web serv…
Have you ever wanted to restrict the users input in a textbox to numbers, and while doing that make sure that they can't 'cheat' by pasting in non-numeric text? Of course you can do that with code you write yourself but it's tedious and error-prone …
Get people started with the process of using Access VBA to control Excel using automation, Microsoft Access can control other applications. An example is the ability to programmatically talk to Excel. Using automation, an Access application can laun…
This lesson covers basic error handling code in Microsoft Excel using VBA. This is the first lesson in a 3-part series that uses code to loop through an Excel spreadsheet in VBA and then fix errors, taking advantage of error handling code.