希望你能帮助解决旧的经典ASP问题。
在我的数据库中,我得到一个带有此值的TEXT字符串:(X*5)/25
strCalString = (X*5)/25
strX = 100
strOutput = replace(strCalString,"X",strX)
然后是我的输出:(100*5)/25
但我想让我的输出为:20
,而不是我的公式字符串,
我怎样才能让它发挥作用。
我试图将strOutput
转换为cint(strOutput)
,但那不起作用。
在谷歌搜索,我可以找到任何东西。
答案 0 :(得分:2)
您需要的是VBScript Eval()
功能:
strCalString = "(X*5)/25"
strX = 100
strOutput = Replace(strCalString, "X", strX)
strResult = Eval(strOutput)