首页 诗词 字典 板报 句子 名言 友答 励志 学校 网站地图
当前位置: 首页 > 教程频道 > 开发语言 > VB >

分两贴议论??

2013-01-01 
分两贴讨论??http://topic.csdn.net/u/20111011/18/9f7878a2-0db2-4da8-87c7-ac7b19a293dd.html?28821感谢

分两贴讨论??
http://topic.csdn.net/u/20111011/18/9f7878a2-0db2-4da8-87c7-ac7b19a293dd.html?28821
感谢各位补充高见!
[解决办法]
果然来了,占个沙发……分两贴议论??
[解决办法]
分两贴议论??给我点分
[解决办法]
神马2个人要好好努力了哈~~
[解决办法]
分两贴议论??
[解决办法]
路过接分
[解决办法]
苦力来了。。。

把正则处理的合并起来完整发下。楼主懒死了。

Private Sub Form_Load()
    Dim s$, i%, isContinue As Boolean, i1%, i2%, reg As Object
    s = "1889/((((845-59)+((4999)*(-8)×((93(-)599)())+((62))())÷62))+666662)"

    Set reg = CreateObject("vbscript.regExp")
    reg.Global = True
    reg.Pattern = "\(([\+\-]
[解决办法]
\d*?)\)"
    Do While reg.Execute(s).Count > 0
        s = reg.Replace(s, "$1")
    Loop
    
    Do
        isContinue = False
        For i = 1 To Len(s)
            If Mid(s, i, 1) = "(" Then
                i1 = getMatch(s, i)
                i2 = IIf(Mid(s, i + 1, 1) = "(", getMatch(s, i + 1), i1)
                If i1 - i2 = 1 Or i2 - i <= 2 Then
                    s = Left(s, i - 1) & Mid(s, i + 1, i2 - i - 1) & Mid(s, i2 + 1)
                    isContinue = True
                End If
            End If
        Next
    Loop Until Not isContinue
    Debug.Print s
End Sub
'得到匹配的括号的位置
Private Function getMatch(strKey$, intPos%) As Integer
    Dim i%, intLCount%, intRCount%
    For i = intPos To Len(strKey)
        If Mid(strKey, i, 1) = "(" Then
            intLCount = intLCount + 1


        ElseIf Mid(strKey, i, 1) = ")" Then
            intRCount = intRCount + 1
            If intRCount = intLCount Then
                getMatch = i
                Exit Function
            End If
        End If
    Next
End Function


1889/(((845-59)+(4999*(-8)×(93-599)+62)÷62)+666662)
[解决办法]
好东西呀。
[解决办法]
还没有结贴啊,我还等着蹭分呢。。。。快点了。。。
[解决办法]
这个需要语法分析,比较专业。
[解决办法]
啥情况?
[解决办法]

热点排行