Hi
This code error is a bit complicated so I hope I can explain it properly.
This is from a ticketing program I am working on.
When the user clicks one of the buttons, say the adult button, the ticket type, price, qty, and total appear in a list box.
One click on any button adds one of that type of ticket.
Here is what is happening. When I start the program several buttons appear each with a kind of ticket. Say Adult, child, Auto.
If I pick any button and click it once it will add one of those tickets to the list box. If I click any OTHER button the program will work as needed regardless of what I do after those 2 initial clicks. The error occurs when the first 2 clicks are on the same button.
I get
" Runtime Error 6015
Cant Add this item. The index is to large"
I hope this is enough code. If you require more please let me know
Thanks
This code error is a bit complicated so I hope I can explain it properly.
This is from a ticketing program I am working on.
When the user clicks one of the buttons, say the adult button, the ticket type, price, qty, and total appear in a list box.
One click on any button adds one of that type of ticket.
Here is what is happening. When I start the program several buttons appear each with a kind of ticket. Say Adult, child, Auto.
If I pick any button and click it once it will add one of those tickets to the list box. If I click any OTHER button the program will work as needed regardless of what I do after those 2 initial clicks. The error occurs when the first 2 clicks are on the same button.
I get
" Runtime Error 6015
Cant Add this item. The index is to large"
Code:
Private Sub UpdateReceipt(intCommodity As Integer)
Dim ReceiptLine As String
ReceiptLine = arrCommodityQty(intCommodity) & ";" & _
arrCommodityDescription(intCommodity) & _
" @ " & _
Format(arrCommodityRate(intCommodity), "$#0.00") & ";" & _
Format(arrCommodityQty(intCommodity) * arrCommodityRate(intCommodity), "$#0.00")
' This next line checks to see if the arrCommodityReceiptLine has been assigned a list count number
' which is the line of the reciept the item is on
If arrCommodityReceiptLine(intCommodity) > 0 Then
' This next line of code removes your original entry on the lst box so it can be replace with
' a new entry with 1 more qty added to it.
' ie: If you remove this next line every time you hit Adult you will get a new Adult
' entry PLUS the original one will incrament 1 so you would get Adult 2 Adult 1 if you his it again
' you will get Adult 3 Adult 2 Adult 1 and so on
lstReceipt.RemoveItem (arrCommodityReceiptLine(intCommodity) - 1)
' This is the line that blows up if the first 2 click are the same button
lstReceipt.AddItem ReceiptLine, (arrCommodityReceiptLine(intCommodity) - 1)
Else
lstReceipt.AddItem (ReceiptLine)
' this line sets the arrCommodityReceiptLine to the list count number of the
'lstBox
' This is the physical line this commodity is listed on
' line 1-3 are populated in sub BuildScreen
arrCommodityReceiptLine(intCommodity) = lstReceipt.ListCount
End If
' the intcommodity is hta number of the mail box
' the arrCommodityRecieptLine is the contents of the mailbox
' the list box has an index and when you remove one thing everything else the index
' for them changes
' If arrCommodityQty(intCommodity) = 0 Then
' lstReceipt.RemoveItem (arrCommodityReceiptLine(intCommodity) - 1)
'
'
' End If
End Sub
I hope this is enough code. If you require more please let me know
Thanks