1:在 text 輸入 131523565
2:msgbox 反映出
輸入 131523565
1:重複 1 次
3:重複 1 次
5:重複 2 次
請高手幫忙... thanks.....
ps:請不要用131523565直接回答.因為這只是舉例的資料值.
2007-03-03 04:21:46 · 2 個解答 · 發問者 iam_1_001 5 in 電腦與網際網路 ➔ 程式設計
下的程式碼,有些改成全形了(因為奇摩無法顯示)
請至以下網址看完正確的程式碼..
http://specterglobe.brinkster.net/v001.html
Dim S$, T$, Msg$, N1, N2%
S = Text.Text
Msg = "輸入" & S
Do Until Len(S) = 0
T = Left(S, 1)
N1 = Len(S)
S = Replace(S, T, "")
N2 = N1 - Len(S) - 1
If N2 Then Msg = Msg & Chr(13) & T & ":重覆" & N2 & "次"
Loop
MsgBox Msg
2007-03-03 11:55:45 補充:
我之前也對愁痕大說過一樣的話...
2007-03-03 06:17:41 · answer #1 · answered by 幽靈 5 · 0⤊ 0⤋
原始碼放於此處
http://tw.myblog.yahoo.com/a15939tedwang/article?mid=2&prev=-1&next=-1
Dim TempString As String
Dim tt(), ttcnt()
Dim ArrayLength As Long
Private Sub Command1_Click()
ArrayLength = 0
ReDim Preserve tt(ArrayLength)
TempString = Trim(Text1.Text)
For i = 1 To Len(TempString)
isDuplicate = False
For j = 0 To UBound(tt)
If Mid(TempString, i, 1) = tt(j) Then
isDuplicate = True
End If
Next
If isDuplicate = False Then
tt(UBound(tt)) = Mid(TempString, i, 1)
ReDim Preserve tt(UBound(tt) 1)
End If
Next
If tt(UBound(tt)) = "" And UBound(tt) > 0 Then
ReDim Preserve tt(UBound(tt) - 1)
End If
ReDim ttcnt(UBound(tt))
For j = 0 To UBound(tt)
For i = 1 To Len(TempString)
If tt(j) = Mid(TempString, i, 1) Then
ttcnt(j) = ttcnt(j) 1
End If
Next
Next
//顯示重複次數
For j = 0 To UBound(tt)
If tt(0) <> "" And ttcnt(j) - 1 > 0 Then
Debug.Print "字元" & tt(j) & ":重複" & ttcnt(j) - 1 & "次"
End If
Next
End Sub
2007-03-03 11:44:37 補充:
replace的做法妙阿
2007-03-03 06:38:46 · answer #2 · answered by 醉愛翡翠珠寶精品 3 · 0⤊ 0⤋