字符串用几种符号一起做分割符 
比如说:有这样一个字符串:”ndjk,dsh jdks?bhsj 123,abc” 
要分成4个数组元素 而不是2个

解决方案 »

  1.   

    dim mystr as string
    dim nLoop as interger
    dim lastpos as intergerdim output(3) as string
    dim nowoutput as intergermystr="ndjk,dsh jdks?bhsj 123,abc"
    lastpos=1
    for nloop=1 to len(mystr)if mid(mystr,nloop,1)="," or mid(mystr,nloop,1)="?" thenoutput(nowoutput)=mid(mystr,lastpos,nloop-lastpos)
    lastpos=nloop+1
    nowoutput=nowoutput + 1end ifnext nloopoutput(3)=mid(mystr,lastpos,len(mystr)-lastpos)
      

  2.   

    修改了下:
    Dim mystr As String
    Dim nLoop As Integer
    Dim lastpos As Integer
    Dim output(3) As String
    Dim nowoutput As Integermystr = "ndjk,dsh jdks?bhsj 123,abc"
    lastpos = 1
    For nLoop = 1 To Len(mystr)
        If Mid(mystr, nLoop, 1) = "," Or Mid(mystr, nLoop, 1) = "?" Then
            output(nowoutput) = Mid(mystr, lastpos, nLoop - lastpos)
            lastpos = nLoop + 1
            nowoutput = nowoutput + 1
        End If
    Next nLoop
    output(3) = Mid(mystr, lastpos, Len(mystr) - lastpos + 1)
      

  3.   

    太复杂了,简单的如这样:s="ndjk,dsh jdks?bhsj 123,abc"
    s=replace(s, "?", ",")
    s=replace(s, "/", ",")
    s=replace(s, "\", ",")
    s=replace(s, ";", ",")
    s=replace(s, "|", ",")'若干种都可以,添加转换就是。dim arr() as string 
    arr=split(s, ",")
      
    ————————————————————————————————————
    现在的人们要求越来越高!事情还是十画还没有一撇,就要源码!