类似
Dim i As Integer = 1
Dim dict As new Dictionary(of String,String)
For Each r As Row In Tables("报名表").rows
Dim s As String
If r.isnull("男选手") = False Then
s = r("男选手")
Else
s = r("女选手")
End If
If dict.ContainsKey(s) Then
r("背号") = dict(s)
Else
r("背号") = Format(i,"0000")
dict.Add(s,r("背号"))
i += 1
End If
Next
如果是我,会增加一个性别列,然后男女选手姓名都放到同一个“姓名列”即可。