Attribute VB_Name = "ModVBScript"


Option Explicit



Public Function FunctionXYZValue(VbscriptUse As Object, stEq As String, xIn As Double, yIn As Double, zIn As Double) As Variant

'Set glVbScript = New MSScriptControl.ScriptControl
VbscriptUse.AddCode "x=" & xIn
VbscriptUse.AddCode "y=" & yIn
VbscriptUse.AddCode "z=" & zIn

 VbscriptUse.AddCode _
        "Function theFunction()" & vbCrLf & _
        "TheFunction  = " & stEq & vbCrLf & _
        "End Function"
On Error GoTo ErrHandler
         
         FunctionXYZValue = VbscriptUse.Eval("theFunction()")
         Exit Function
ErrHandler:
    Beep
    MsgBox Err.Description
End Function


Public Function FunctionValues(VbscriptUse As Object, stEq As String, StVarsIn() As String, VVarsIn() As Double) As Variant

'Set glVbScript = New MSScriptControl.ScriptControl
Dim Nvar As Integer, i As Integer ', st As String
Nvar = UBound(VVarsIn)

For i = 1 To Nvar
'st = StVarsIn(i) & " = " & VvarsIn(i)
VbscriptUse.AddCode StVarsIn(i) & " = " & VVarsIn(i)
'MsgBox ("st=" & st)
Next i

 VbscriptUse.AddCode _
        "Function theFunction()" & vbCrLf & _
        "TheFunction  = " & stEq & vbCrLf & _
        "End Function"
On Error GoTo ErrHandler
         
         FunctionValues = VbscriptUse.Eval("theFunction()")
         Exit Function
ErrHandler:
    Beep
    MsgBox Err.Description
End Function




