nordscan
nordscan

Reputation: 137

VB6 - make the result numbers i a sequence

Hello i have this VB6 code

Public Sub ShowOperations()

    Dim Drw As Drawing
    Set Drw = App.ActiveDrawing

    Dim Ops As Operations
    Set Ops = Drw.Operations

    Dim Op As Operation
    For Each Op In Ops

        For Each SubOp In Op.SubOperations

            Debug.Print Op.Number & "-" & Op.SubOperations.Count

        Next SubOp
    Next Op
End Sub

In operations can be more sub operations. but my result is like this

1-1
2-2
2-2
3-1
4-3
4-3
4-3
5-1

As you can see for operation 2 it show me total 2sub operations... but i need that the reseult will be

1-1
2-1
2-2
3-1
4-1
4-2
4-3
5-1

can me somebody help with this...

thank you

Upvotes: 0

Views: 43

Answers (1)

user3598756
user3598756

Reputation: 29421

just add a SubOp counter:

Dim nSubOp As Long '<--| declare a SubOp counter
For Each Op In Ops
    nSubOp = 0 '<--| initialize SubOp counter
    For Each SubOp In Op.SubOperations
        nSubOp = nSubOp + 1 '<--| update SubOp counter
        Debug.Print Op.Number & "-" & nSubOp
    Next SubOp
Next Op

Upvotes: 1

Related Questions