不排序也可得到结果,代码如下(其中“卫孙”和“褚吴”作为复姓不在索引表里未统计,所以和题主结果有出入):
程序代码:
Private Sub Command1_Click()
Dim i As Integer, j As Integer, k As Integer, m() As String, n() As String, s As String, t As String
s = "赵,钱,孙,李,周,吴,郑,王,冯,陈,褚,卫,蒋,沈,韩,杨,朱,秦,尤,许,何,吕,施,张,孔,曹"
t = Text1.Text & ","
m = Split(s, ",")
ReDim n(UBound(m))
For i = 0 To UBound(m)
j = 1
k = 0
While InStr(j, t, m(i) & ",")
k = k + 1
j = InStr(j, t, m(i) & ",") + 1
Wend
n(k) = n(k) & m(i) & ","
Next
Text2 = ""
For i = 0 To UBound(n)
If n(i) <> "" Then
Text2 = Text2 & "【共" & i & "人次】:" & n(i) & "(" & Len(n(i)) / 2 & "个姓)" & vbCrLf
End If
Next
End Sub
Private Sub Form_Load()
Text1.Text = "钱,孙,李,周,吴,郑,王,冯,陈,褚,卫,蒋,沈,韩,杨,钱,孙,李,周,吴,冯,陈,褚,卫孙,李,周,吴,郑,孙,李,周,吴,郑,王,冯,陈,褚,卫,蒋,王,冯,陈,褚吴,郑,王,冯,陈,,李,周,吴,,冯,陈,褚"
End Sub