对每个字符
     查找其后是否有相同的字符
     如果有 返回 true返回 false

解决方案 »

  1.   

    Dim isfind As Boolean
        Dim Strx As String
        Dim strY As String
        isfind = False
        For i = 1 To Len("aab")
            Strx = Mid("aab", i, 1)
            For j = i + 1 To Len("aab")
                strY = Mid("aab", j, 1)
                If Strx = strY Then
                    isfind = True
                    Exit Sub
                End If
            Next
        Next
        If isfind = True Then
            找到
        Else
            没有
        End If
      

  2.   

    Private Function IsDuplicate(ByVal strInput As String) As Boolean
        Dim lngI As Long
        Dim lngJ As Long
        
        IsDuplicate = False
        
        For lngI = 1 To Len(strInput)
            For lngJ = lngI + 1 To Len(strInput)
                If Mid(strInput, lngI, 1) = Mid(strInput, lngJ, 1) Then
                    MsgBox Mid(strInput, lngI, 1) & "-" & Mid(strInput, lngJ, 1)
                    IsDuplicate = True
                    Exit Function
                End If
            Next
        Next
    End Function
      

  3.   

    给分方法:http://www.csdn.net/help/over.asp
      

  4.   

    Private Function CheckString(ByVal strString As String) As Boolean
    Dim i As Long
    CheckString = False
    For i = 1 To Len(strString)
        If InStr(i + 1, strString, Mid(strString, i, 1)) Then
            CheckString = True
            Exit For
        End If
    Next
    End Function
      

  5.   

    贴一段:《电脑》杂志1998年第4期    暨南大学软件工具研究所  吴锡桑 
    □ 怎样取得一个字符串在另外一个字符串中出现的次数? 
    Public Function sCount(String1 As String, String2 As String) As Integer 
        Dim I As Integer, iCount As Integer 
        I = 1 
        Do 
              If (I > Len(String1)) Then Exit Do 
              I = InStr(I, String1, String2, vbTextCompare) 
              If I Then 
                  iCount = iCount + 1 
                  I = I + 2 
                  DoEvents 
              End If 
        Loop While I 
        sCount = iCount 
    End Function  □ 怎样在一个字符串中删除里面的另外一个字符串? 
    Public Sub sRemove(String1 As String, String2 As String) 
        Dim I As Integer 
        I = 1 
        Do 
          If (I > Len(String1)) Then Exit Do 
          I = InStr(I, String1, String2) 
          If I Then 
            String1 = Left$(String1, I - 1) + Mid$(String1, I + Len(String2)+1) 
            I = I + 2 
            DoEvents 
          End If 
        Loop While I 
    End Sub □ 怎样在一个字符串中替换里面的另外一个字符串? 
    Public Sub sReplace(String1 As String, String2 As String, RepString As String) 
        Dim I As Integer 
        I = 1 
        Do 
        If (I > Len(String1)) Then Exit Do 
        I = InStr(I, String1, String2) 
        If I Then 
            String1 = Left$(String1, I - 1) + RepString + Mid$(String1, I + Len(S 
    tring2)+1 ) 
            I = I + 2 
            DoEvents 
        End If 
        Loop While I 
    End Sub □ 如何计算一个字符串中的行数? 
    Function CountStringLine(src_string As String) As Integer 
    On Error Resume Next 
    Dim string_flag As Integer 
    Dim line_cnt As Integer 
    Dim test_string As String 
    line_cnt = 0  '初始--> 行数为1 
    string_flag = 1  '标志为1 
    test_string = src_string 
    DoEvents 
    Do 
    line_cnt = line_cnt + 1 
    string_flag = InStr(test_string, vbCrLf)  ’判断回车换行 
    test_string = Right(test_string, Len(test_string) - string_flag - 1) 
    Loop Until string_flag <= 0 
    CountStringLine = line_cnt 
    End Function □ 如何从一个字符串中读取一行字符? 
    Function ReadStringLine(src_str As String, lineno As Integer) As String 
    On Error Resume Next 
    Dim string_flag As Integer 
    Dim line_cnt As Integer 
    Dim test_string As String 
    Dim ret_string As String 
    line_cnt = 0  '初始--> 行数为1 
    string_flag = 1  '标志为1 
    test_string = Right(src_str, 2) 
    If test_string <> vbCrLf Then 
    test_string = src_str + vbCrLf 
    Else 
    test_string = src_str 
    End If 
    DoEvents 
    Do 
    line_cnt = line_cnt + 1 
    string_flag = InStr(test_string, vbCrLf) 
    ret_string = Left(test_string, string_flag) 
    test_string = Right(test_string, Len(test_string) - string_flag - 1) 
    Loop Until lineno <= line_cnt 
    'If line_cnt = 1 Then 
    '  ReadStringLine = ret_string 
    'Else 
    ReadStringLine = Left(ret_string, Len(ret_string) - 1) 
    'End If 
    End Function
      

  6.   

    Private Function check(str As String)
        Dim i As Integer
        Dim j As Integer
        For i = 1 To Len(str)
            For j = 1 To Len(str)
                If i <> j And (Mid(str, i, 1)) = (Mid(str, j, 1)) Then
                    check = False
                    Exit Function
                End If
            Next j
        Next i
        check = True
    End Function
      

  7.   

    对我刚才的补充:我会成有重复的输出FALSE,得改一下,是:
    Private Function check(str As String)
        Dim i As Integer
        Dim j As Integer
        For i = 1 To Len(str)
            For j = 1 To Len(str)
                If i <> j And (Mid(str, i, 1)) = (Mid(str, j, 1)) Then
                    check = True
                    Exit Function
                End If
            Next j
        Next i
        check = False
    End Function