现在要实现以下功能:
           输入一个字符串,程序要把它拆分成一个一个的字符,并在每两个字符之间加入一个“&”分隔符,重新生成一个新的字符串。
    例如:
           从ComboBox输入:"csdn技术论坛"
           输出:          "&c&s&d&n&技&术&论&坛&"输入可以是英文也可以是中文,字符串长度可以变化,求一代码,先谢谢各位大侠了^_^

解决方案 »

  1.   

    Private Sub Command1_Click()
    Dim str As String
    Dim str1 As String
    Dim i As Integer
    str = Text1For i = 1 To Len(str)
        str1 = str1 & "&" & Mid(str, i, 1)
    Nextstr1 = str1 & "&"  '最后个 &Debug.Print str1
    End Sub
      

  2.   


    Private Function GetAndS(s As String) As String
        
        Dim ts As String, i As Integer
        For i = 1 To Len(s)
            ts = ts & Mid(s, i, 1) & "&"
        Next i
        GetAndS = Left(ts, Len(ts) - 1)
        
    End FunctionPrivate Sub Command1_Click()
        
        Print GetAndS("CS中文")
        
    End Sub
      

  3.   


    For i = 1 To Len(字符串)
    xx = xx & "&" & Mid(Me.Text1, i, 1)
    Next i
    字符串= xx & "&"
      

  4.   

    chr(38) 或者 "&" 都可以代替
      

  5.   

    Private Sub Command1_Click()
    MsgBox outstring("csdn技术论坛")
    End Sub
    Function outstring(ByVal instring As String) As String
    Dim i As Integer, temp() As String
    ReDim temp(Len(instring) + 1)
    For i = 1 To Len(instring)
    temp(i) = Mid(instring, i, 1)
    Next
    outstring = Join(temp, "&")
    Erase temp
    End Function
      

  6.   

    Private Sub Command1_Click()
        Dim s As String, n As String, i As Long
        s = "csdn技术论坛"
        For i = 1 To Len(s)
            n = n & "&" & Mid(s, i, 1)
        Next i
        n = n & "&"
        MsgBox n
    End Sub
      

  7.   

    下面代码的好处是速度特别快。Public Function StringReMoveCode(ByVal pString As String, Optional ByVal pReMoveCode = &H26) As String
      '去码函数
      Dim tOutString As String
      
      Dim tReMoveString As String
      
      tReMoveString = Chr(pReMoveCode)
      
      tOutString = Replace(pString, tReMoveString, "")
      
      StringReMoveCode = tOutString
    End FunctionPublic Function StringAddCode(ByVal pString As String, Optional ByVal pAddCode = &H26) As String
      '加码函数
      Dim tOutString As String
      
      Dim tSurBytes() As Byte
      Dim tSurBytes_Length As Byte
      Dim tSurBytes_Count As Byte
      
      Dim tDesBytes() As Byte
      Dim tDesBytes_Length As Byte
      Dim tDesBytes_Count As Byte
        
      tSurBytes() = pString
      tSurBytes_Length = UBound(tSurBytes())
      tSurBytes_Count = tSurBytes_Length + 1
      
      tDesBytes_Count = tSurBytes_Count * 2
      tDesBytes_Length = tDesBytes_Count - 1
      
      ReDim tDesBytes(tDesBytes_Length)
      
      Dim tSurIndex_Base As Long
      Dim tSurIndex As Long
      
      Dim tDesIndex As Long
      Dim tDesIndex_Base As Long
      Dim tDesIndex_AddCode As Long
      
      Dim tPatchIndex As Long
      
      For tSurIndex_Base = 0 To tSurBytes_Length Step 2
        
        tDesIndex_AddCode = tSurIndex_Base * 2
        tDesIndex_Base = tDesIndex_AddCode + 2
        
        For tPatchIndex = 0 To 1
          tSurIndex = tSurIndex_Base + tPatchIndex
          tDesIndex = tDesIndex_Base + tPatchIndex
          
          tDesBytes(tDesIndex) = tSurBytes(tSurIndex)
        
        Next
        
        tDesBytes(tDesIndex_AddCode) = pAddCode
        
      Next
        
      tOutString = tDesBytes()
      
      StringAddCode = tOutString
    End FunctionPrivate Sub Form_Load()
      '测试代码
      Dim tString_Sur As String
      Dim tString_AddCode As String
      Dim tString_ReMoveCode As String
      
      tString_Sur = "KiteGirl小仙妹是个好孩子!"
      
      tString_AddCode = StringAddCode(tString_Sur)
      tString_ReMoveCode = StringReMoveCode(tString_AddCode)
      
      Text1.Text = tString_Sur
      Text2.Text = tString_AddCode
      Text3.Text = tString_ReMoveCode
      
    End Sub