I'm close to the end of this code, but there is a problem with it.
Public SumXCollection As Collection
Public artikal As String
...
Private Sub Sub1()
...
artikal = Product.Text
...
End Sub
Private Sub Sub2()
...
If (some item exists) Then
...
...
'update the corresponding object of the SumX collection !!!!!!!!!
Set zx = SumXCollection(artikal)
zx.ColorXX = Color.Text
zx.TotalXX = ActiveSheet.Cells(begin1 + i, 11)
Else
...
...
'create a new object of the SumX coolection
Set zx = New SumX
zx.CodeXX = artikal
zx.ColorXX = Color.Text
zx.TotalXX = ActiveSheet.Cells(stepx, 11)
SumXCollection.Add zx, zx.CodeXX
...
End If
...
End Sub
'Class Module named 'SumX'
Option Explicit
Private pCodeXX As String
Private pColorXX As String
Private pTotalXX As String
Public Property Get CodeXX() As String
CodeXX = pCodeXX
End Property
Public Property Let CodeXX(ByVal vNewValue As String)
pCodeXX = vNewValue
End Property
Public Property Get ColorXX() As String
ColorXX = pColorXX
End Property
Public Property Let ColorXX(ByVal vNewValue As String)
pColorXX = vNewValue
End Property
Public Property Get TotalXX() As String
TotalXX = pTotalXX
End Property
Public Property Let TotalXX(ByVal vNewValue As String)
TotalXX = vNewValue
End Property
and i get :
Compile error:
Variable not defined
on 'Set zx = SumXCollection(artikal)' in Sub2().
What is particularly odd is that the code shouldn't enter the first part of the If statement immediately, because in the first pass the item (from the condition) doesn't exist, so the code must drop to Else part of the If statement, where a zx object needs to be created.
So that, every new zx object is created in the second (Else) part of the If st., and every existing one is updated in the first part.
What's wrong with this?
Thanks a lot in advance
Bookmarks