如何用Like判断公式的正确性
公式 计算结果 正确性
2*3 → 6 → TRUE
6-2-7*9+8 → -51 → TRUE
30+5/6-9 → 21.83333333 → TRUE
(5+6)*9 → 99 → FALSE
5+6) → #VALUE! → FALSE
sin(30*pi()/180) → 0.5 → FALSE
cos(30*pi()/181) → 0.867468184 → FALSE
tan(30*pi()/182) → 0.569703809 → FALSE
150+500-sqrt(500^2-(240*cos(5.49779))^2) → 179.6811342 → FALSE
************************************
目标需求,如何处理 "*[!0-9+-\*/]*" ,无#VALUE的条件下,将False改为True
***************************************
++++++++++++++
Function IsGoodFormula(ByVal sString As String) As Boolean
If Not sString Like "*[!0-9+-\*/]*" Then IsGoodFormula = True
End Function
++++++++++++++
Function oEval(Str As String)
oEval = Application.Evaluate(Str)
End Function