回覆列表
  • 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 = sEnd Sub

  • 中秋節和大豐收的關聯?
  • 青少年如何將資訊學競賽納入學業規劃?