|
楼主 |
发表于 2020-6-8 14:00:01
|
显示全部楼层
哈哈,我知道了,自己回答吧
Public Function Test(ByVal Expression As String) As Single
On Error GoTo ErrorHandle
Dim domSource As New DOMDocument
Dim domStyleSheet As New DOMDocument
Dim domResult As New DOMDocument
Dim str As String
str = "<?xml version='1.0' encoding='GB2312'?>" + vbCrLf
str = str + "<xml>"
str = str + "<expression>"
str = str + Expression
str = str + "</expression>"
str = str + "</xml>"
domSource.loadXML str
str = "<?xml version='1.0' encoding='gb2312'?>" + vbCrLf
str = str + "<xsl:stylesheet xmlns:xsl='http://www.w3.org/TR/WD-xsl'>"
str = str + "<xsl:template match='/'>"
str = str + "<Result>"
str = str + "<xsl:eval language='vbscript'>Eval(me.text)</xsl:eval>"
str = str + "</Result>"
str = str + "</xsl:template>"
str = str + "</xsl:stylesheet>"
domStyleSheet.loadXML str
domSource.transformNodeToObject domStyleSheet, domResult
Test = domResult.Text
' Test = True
Exit Function
ErrorHandle:
Test = False
End Function
|
|