Mark duplicate features in attribute table with Field Calculator, update to Arc10

Discussion created by cwoodward on Sep 5, 2011
Latest reply on Feb 5, 2014 by shivamparashari1
I've got a handy piece of VB script that I used to routinely run on Arc9.3 to mark duplicate features in an attribute table based upon unique ID's in the table.  I typically use this on repeat points that appear within a dataset more than once (based upon ID value, Date/Time and position).  The problem is, the script won't work in Arc10 and I wasn't the original author so I'm not sure how to update it. 

I'm running Arc10 SP2 on a Windows 7 and/or XP machine.  My typical workflow is to concatenate a unique ID 'Unique_ID' (text, 255) based upon several attributes (say ID, Date/Time, Lat./Long).  I then create a attribute called 'dup' of a short interger type.  I run the field calculator on the dup field and load the following script and what it would normally do is to mark duplicate values of the Unique_ID value with a 1 value.  Both records wouldn't be marked, only the second or greater duplicate Unique_ID value record. 

Within the field calculator, I'd have the "Show Codeblock" checked and the following in the "Pre-Logic Script Code" area:

Static d As Object
Static i As Long
Dim iDup As Integer
Dim sField
'Replace the field name bellow
sField = [Chris_ID]
If (i = 0) Then
  Set d = CreateObject("Scripting.Dictionary")
End If
If (d.Exists(CStr(sField))) Then
  iDup = 1
  d.Add CStr(sField), 1
  iDup = 0
End If
i = i + 1

The following would also be in the bottom part: Dup=iDup

If someone could help me with updating this VB script for Arc10, it would be greatly appreciated!