n = 0
While Not(doc Is Nothing)
If Isnull(Arraygetindex(Array1,key)) Then
Redim Preserve Array1(n)
Array1(n) = key
n = n + 1
Else
If (doc.SubmitDoc(0) = "N") Then '**there is a NameUser within this doc
doc.SubmitDoc = "Y"
Call doc.Save(True,True)
End If
End If
End If
I have a log that has to show for each user that receive those documents as:
==> User1 received documents: 2 (2 documents marked as “Y” for this user)
==> User2 received documents: 1
==> User3 received documents: 5
How can I do this? Show the number for each user based on this array!
It’s not completely clear what you’re trying to do.
I assume key contains the username retrieved from the document (though you don’t show that line). So your logic is, first, have we encountered this user before; if not, add them to the list, otherwise do some processing on the document. So you don’t want to process the first document you encounter for each user? That seems a little odd.
Since you need to keep track of two things – a list of usernames and an associated count for each user – you need a more complex data structure than an array, which can only store one thing – the names or the counts.
The easiest way to do this is with a List variable.
Dim usercounts List As Integer
If Iselement(usercounts(key)) Then
'already saw this user, so process the document
… (process document here)
usercounts(key) = usercounts(key) + 1
Else ’ new user, ignore the document but remember the name in case they have another.
usercounts(key) = 0
End If
…
Forall count In usercounts
if count > 0 then Print listtag(count) & " received " & count