English Deutsch Français Italiano Español Português 繁體中文 Bahasa Indonesia Tiếng Việt ภาษาไทย
所有分類

如何得知一字串是否出現重複的字元?
Text2
16個字

2006-04-15 20:42:33 · 4 個解答 · 發問者 ? 2 in 電腦與網際網路 程式設計

4 個解答

Private Sub Command1_Click()
Dim i As Integer, j As Integer
Dim Rep As String, Check As String

For i = 1 To Len(Text1.Text) - 1
Rep = UCase(Mid(Text1.Text, i, 1))
For j = i + 1 To Len(Text1.Text)
If Rep = UCase(Mid(Text1.Text, j, 1)) Then
Check = Check + " " + Rep
End If
Next
Rep = ""
Next
MsgBox "重覆字元:" + Check
End Sub

2006-04-15 21:14:29 · answer #1 · answered by Money 5 · 0 0

Private Sub Command1_Click()    Dim S As String    Dim R As String    Dim M As String    Dim i As Integer    S = ""    For i = 1 To Len(Text2.Text)        M = Mid(Text2.Text, i, 1)        If InStr(R, M) = 0 Then            If Len(Replace(Text2.Text, M, "")) <> Len(Text2.Text) - 1 Then                S = S & M & " 重複 " & Len(Text2.Text) - Len(Replace(Text2.Text, M, "")) - 1 & " 次" & vbCrLf            End If        End If        R = R + M    Next    If Len(S) = 0 Then        MsgBox "無重複字元"    Else        MsgBox S    End IfEnd Sub

2006-04-18 04:58:04 · answer #2 · answered by 世賢 7 · 0 0

大大們都好厲害...能不能幫我看一下這題...
http://tw.knowledge.yahoo.com/question/?qid=1206041519170

拜託~ 要交作業了,所以很急...><

2006-04-16 05:04:54 · answer #3 · answered by milu 2 · 0 0

Private Sub Command1_Click()Dim I%, S$, S1$For I = 1 To Len(Text1) - 1    S1 = Mid$(Text1, I, 1)    If InStr(I + 1, Text1, S1, vbTextCompare) Then       If InStr(S, S1) = 0 Then S = S & S1 & ","    End IfNextIf Len(S) Then   MsgBox "有重複字元 : " & Left$(S, Len(S) - 1)Else   MsgBox "無重複字元"End IfEnd Sub

2006-04-15 23:43:19 · answer #4 · answered by W.J.S. 7 · 0 0

fedest.com, questions and answers