I'm writing a POS application for a course. I'm having trouble accessing itemList of type ArrayList in a different class. Below is my code of the two classes. Is it possible to access an arrayList in another class (i.e. inside Transaction)?
Public Class Item
'Declares item variables
Public itemName As String
Public itemPrice As Decimal
Public itemQty As Integer
Public itemSku As Long
Public itemList As New ArrayList
Public newItem As Item
'Method passes details of item
Public Sub AddItem(itemSku, itemName, itemPrice, itemQty)
itemSku = newItem.itemSku
itemName = newItem.itemName
itemPrice = newItem.itemPrice
itemQty = newItem.itemQty
itemList.Add(newItem) 'adds newItem to arrayList of items itemList
End Sub
End Class
Public Class Transaction
Dim subtotal As Decimal
Dim tax As Decimal
Dim total As Decimal
Dim paymentType As String
Public Function calculateBalance()
For count As Integer = 0 To itemList.Count 'TRYING TO ACCESS ARRAYLIST HERE
Next
End Function
End Class