土木堡是土木镇吗:用vba添加运算符,使其成立等式成立

来源:百度文库 编辑:我要文章网 时间:2019/11/15 02:25:02
用vba添加运算符,使其成立等式成立 

题目:在下面算式中添加4个运算符,使其成立:5 5   5   5 5=100。用vba怎样编程

Sub hh5个5等于100()
Dim HH1%, hh2%, hh3%, hh4%, MYnumber%, ll%
MYnumber = 5
ll = 1
myshuzu = Array("+", "-", "*", "/")
For HH1 = LBound(myshuzu) To UBound(myshuzu)
    For hh2 = LBound(myshuzu) To UBound(myshuzu)
        For hh3 = LBound(myshuzu) To UBound(myshuzu)
            For hh4 = LBound(myshuzu) To UBound(myshuzu)
                If Evaluate(MYnumber & myshuzu(HH1) & MYnumber & myshuzu(hh2) & MYnumber & myshuzu(hh3) & MYnumber & myshuzu(hh4) & MYnumber) = 100 Then
                   Cells(ll, 1) = MYnumber & myshuzu(HH1) & MYnumber & myshuzu(hh2) & MYnumber & myshuzu(hh3) & MYnumber & myshuzu(hh4) & MYnumber & " = 100"
                 ll = ll + 1
                End If
            Next
        Next
    Next
Next
End Sub