1个回答
展开全部
方法有许多种,给你一个字典的用法,比较方便一些!
代码如下,详细可下载附件测试!
Private Sub Command1_Click()
Dim dc As Object, s As String, iMax As Integer, n As Integer
Set dc = CreateObject("Scripting.dictionary")
Dim i As Integer
For i = 1 To Len(Text1.Text)
s = Mid(Text1.Text, i, 1)
If Not dc.Exists(s) Then
dc(s) = 1
Else
dc(s) = Val(dc(s)) + 1
If iMax < Val(dc(s)) Then iMax = Val(dc(s))
End If
Next
s = ""
Dim ar
ar = dc.keys
For i = iMax To 1 Step -1
For n = 0 To UBound(ar)
If dc(ar(n)) = i Then s = s & ar(n) & "(" & i & ")"
Next
Next
Text2.Text = s
End Sub
本回答被提问者采纳
已赞过
已踩过<
评论
收起
你对这个回答的评价是?
推荐律师服务:
若未解决您的问题,请您详细描述您的问题,通过百度律临进行免费专业咨询