Attribute VB_Name = "ModTools"
Option Explicit
Public Function PartialDif(vbScriptUse As Object, stEq As String, VvarsSt() As String, VvarsV() As Double, nIndexOfVar As Integer) As Double
 Dim i As Integer
 Dim p1 As Double, p2 As Double
 
 Dim VvarsTpt() As Double
 Dim nUnknown As Integer
 Dim eps As Double
 eps = 0.000001
 nUnknown = UBound(VvarsSt)
 For i = 1 To nUnknown
 ReDim Preserve VvarsTpt(1 To i)
 VvarsTpt(i) = VvarsV(i)
 Next i
 
 p1 = FunctionValues(vbScriptUse, stEq, VvarsSt, VvarsTpt)
 VvarsTpt(nIndexOfVar) = VvarsV(nIndexOfVar) + eps
 p2 = FunctionValues(vbScriptUse, stEq, VvarsSt, VvarsTpt)
 Dim pvpvx As Double
 pvpvx = (p2 - p1) / eps
 'MsgBox ("pvpv1=" & pvpvx)
PartialDif = pvpvx
End Function
