如题:
从数组
000
000
234
236
174
654
123
589
478
654
346
589
234
000
457
589
589
中取出现次数为2-3次的
即新数组:
000 234 654
请帮忙!谢谢!
ReDim Preserve
这个是保留数组数据的,只改变最后一维的下标,这个知道的,可是还是不会写啊
我这里有统计次数的代码,只是该如何选取呢?
Private Sub Command2_Click()
Dim StrB(999) As String
Dim arn(999) As Integer
Dim totnumber As Integer
Dim StrA() As String
StrA() = Split(RichTextBox1.Text, vbCrLf)
Dim TepAll As String
Dim i As Integer, j As Integer
Do Until i = UBound(StrA)
For j = 0 To 999
If StrB(j) = StrA(i) Then
arn(j) = arn(j) + 1
Exit For
ElseIf StrB(j) = Empty Then
StrB(j) = StrA(i)
arn(j) = 1
totnumber = j
Exit For
End If
Next j
i = i + 1
Loop
For i = 0 To totnumber
TepAll = TepAll & StrB(i) & "出现次数:" & arn(i) & vbCrLf
Next i
RichTextBox2 = TepAll
End Sub