例如
文本框内容:
虎,龙,蛇,马,羊,虎,
猴,鸡,狗,狗,鼠,
牛,兔,龙,蛇,羊,龙,
猴,狗,猪,鼠,猪,虎,
龙,蛇,马,羊,鸡,
狗,猪,鼠,虎,蛇,
猴,猴,鸡,狗,
猪,牛,牛,龙,蛇,改为:
虎,龙,蛇,马,羊,
猴,鸡,狗,鼠,
牛,兔,龙,蛇,羊,
猴,狗,猪,鼠,虎,
龙,蛇,马,羊,鸡,
狗,猪,鼠,虎,蛇,
猴,鸡,狗,
猪,牛,龙,蛇,意思就是删除每行重复的字符.谢谢 给个代码

解决方案 »

  1.   

    按行读入内容到str1变量里
    dim i as long 
    dim str2 as string
    dim str3 as stringstr2=""
    i=len(str1)
    do while i>0
       str3=left(str1,1)
       str2=str2 & str3
       str1=replace(mid(str1,2),str3,"")
       i=len(str1)
    loop
    MsgBox str2
      

  2.   

    这类问题我一般不回答,提此类问题的人说明他不屑于动脑。
    Good Luck!
      

  3.   

    一楼的程序稍微修改下就可以了.strTmp=""
    arrTmp=split(strLine,",")for i=0 to ubound(arrtmp)
        if trim(arrTmp(i))<>"" then
            if instr(strTmp,trim(arrTmp(i)))<1 then
                strtmp=trim(arrTmp(i))&","
            end if
        end if
    nextmsgbox strtmp如果没有分割符,那就用替换法.修改一下一楼的程序就可以了.
      

  4.   

    VBAdvisor(Sunlight) ( ) 信誉:100    Blog   加为好友  2007-07-11 12:06:13  得分: 0  
     
     
       这类问题我一般不回答,提此类问题的人说明他不屑于动脑。
    Good Luck!
      
     
    -------------真晕,要是动脑都有用的话大家都不用上学了,我刚学没几天,怎么动脑也不会啊.
      

  5.   

    现在就是不知道怎样把两个循环组合起来
    处理一行的循环
    strNum = Text1.Text
    arrNum = Split(strNum, ",")
    strResult = CStr(arrNum(0))
    For ii = 1 To UBound(arrNum)
    If InStr(strResult, arrNum(ii)) = 0 Then
    strResult = strResult & "," & arrNum(ii)
    Text2.Text = strResult处理多行的循环
    kof = Text1.Text
    kofe = Split(kof, vbCrLf)
      

  6.   

    Private Sub Command1_Click()
    Dim strText As String
    strText = Text1.Text
    Dim i As Integer, j As Integer, pos1 As Integer, pos2 As Integer
    Dim strTmp() As String, str1 As String
    Do
        pos2 = InStr(pos1 + 1, strText, vbCrLf, vbTextCompare)
        If pos2 = 0 Then pos2 = Len(strText)
        strTmp = Split(Mid(strText, pos1 + 1, pos2 - pos1 - 1), ",")
        For j = UBound(strTmp) To LBound(strTmp) Step -1
            For i = j - 1 To LBound(strTmp) Step -1
                If strTmp(j) = strTmp(i) Then
                    strTmp(j) = ""
                    Exit For
                End If
            Next i
        Next j
        For i = LBound(strTmp) To UBound(strTmp)
            If strTmp(i) <> "" Then str1 = str1 & strTmp(i) & ","
        Next i
        str1 = str1 & vbCrLf
        If pos2 <> Len(strText) Then pos1 = pos2 Else pos1 = 0
    Loop While pos1 > 0
    Text1.Text = str1
    End Sub
      

  7.   

    Private Sub Command1_Click()
    Dim strText As String
    strText = Text1.Text
    Dim i As Integer, j As Integer, pos1 As Integer, pos2 As Integer
    Dim strTmp() As String, str1 As String
    Do
    pos2 = InStr(pos1 + 1, strText, vbCrLf, vbTextCompare)
    If pos2 = 0 Then pos2 = Len(strText)
    strTmp = Split(Mid(strText, pos1 + 1, pos2 - pos1 - 1), ",")
    For j = UBound(strTmp) To LBound(strTmp) Step -1
    For i = j - 1 To LBound(strTmp) Step -1
    If strTmp(j) = strTmp(i) Then
    strTmp(j) = ""
    Exit For
    End If
    Next i
    Next j
    For i = LBound(strTmp) To UBound(strTmp)
    If strTmp(i) <> "" Then str1 = str1 & strTmp(i) & ","
    Next i
    str1 = str1 & vbCrLf
    If pos2 <> Len(strText) Then pos1 = pos2 Else pos1 = 0
    Loop While pos1 > 0
    Text1.Text = str1
    End Sub
      

  8.   

    呵呵,我倒是回答了,一分没给
    clear_zero复制我的代码,还有5分呢