Home > Community > Automation and VBA > Aufruf einer eigenen FPScript-Funktion > Antwort auf: Aufruf einer eigenen FPScript-Funktion

#9193
Bernhard KantzBernhard Kantz
Teilnehmer

You have to distinguish if you want to call a FPScript function with one argument for different values or if you want to call a FPScript function with more than one argument. The following example shows how it works:

Sub test()

Dim myFormel As Formula
Dim mySignal As Signal
Dim myVariant As Variant
Dim testWert1 As Variant
Dim testWert2 As Variant
testWert1 = Array(“100”, “1”)
testWert2 = Array(“200”, “2”)

With ActiveDatabase.RootFolder
‘ Funktion zum Testen bekannt machen
Set myFormel = .Object(“FktTest”, fpObjectTypeFormula)
‘ Prüfen, ob es eine Formel ist
If TypeOf myFormel Is Formula Then Debug.Print “myFormel ist Formel”
‘ Ausgabe der Formel
Debug.Print myFormel.Formula
myVariant = myFormel.Call(testWert1, testWert2)
Debug.Print myVariant(0, 0)
Debug.Print myVariant(0, 1)
Debug.Print myVariant(1, 0)
Debug.Print myVariant(1, 1)
End With
End Sub

support@weisang.com