例如有不确定多少行的一个文件,内容如下
lkdsk2098423(aaafa)fdsflk
38490832(bdd)klj392
Kds9fsdf(894375)
l00939u47(kdii)
....
...
....
在text里面输入带有回车符的文本后,点击Command,就会留下每行括号内的内容(不带括号的)!
aaafa
bdd
894375
kdii
.....
....
....

解决方案 »

  1.   

    用2次instr确定前后括号位置i和j,再mid(s,i,j-i)得结果
      

  2.   

    点击Command
    dim strArry() as string
    dim strT as string
    dim i as long
    dim j as long
    dim n as long
     
    strArry = split(text1. text,vbcrlf)
    text1. text = ""
    for i =0 to ubound(strArry)
    strT  = strArry(i)
    j=instr(strT,"(")
    n=instr(strT,")")
    text1. text =text1. text & mid(strT,j ,n-j )
    next
      

  3.   

    楼上的兄弟,还差一点点,我测试后出现如下结果
    (aaafa(bdd(894375(kdii
    左面的括号没有去掉,而且把火车符给去掉了
    麻烦再改一改
      

  4.   

    '此代码由“正则测试工具 v1.1.34”自动生成,请直接调用TestReg过程
    Private Sub TestReg()
        Dim strData As String
        Dim reg As Object
        Dim matchs As Object, match As Object    strData = "lkdsk2098423(aaafa)fdsflk"  &  vbCrLf  & _
                  "38490832(bdd)klj392"  &  vbCrLf  & _
                  "Kds9fsdf(894375)"  &  vbCrLf  & _
                  "l00939u47(kdii)"    Set reg = CreateObject("vbscript.regExp")
        reg.Global = True
        reg.IgnoreCase = True
        reg.MultiLine = True
        reg.Pattern = "\((.*?)\)"
        Set matchs = reg.Execute(strData)
        For Each match In matchs
            'Debug.Print match.Value
            Debug.Print match.SubMatches(0)
        Next
    End Sub
      

  5.   

    点击Command
    dim strArry() as string
    dim strT as string
    dim i as long
     
    strArry = split(text1. text,vbcrlf)
    text1. text = ""
    for i =0 to ubound(strArry)
    strT = strArry(i)
    text1. text =text1. text & split(split(strT,"(")(1),")")(0)
    next
      

  6.   

    改一下代码:dim strArry() as string
    dim strT as string
    dim i as long
    dim j as long
    dim n as long
     
    strArry = split(text1. text,vbcrlf)
    text1. text = ""
    for i =0 to ubound(strArry)
       strT = strArry(i)
       j=instr(strT,"(")
       n=instr(strT,")")
       text1. text =text1. text & mid(strT,j+1 ,n-j ) & vbCrlf
    next i