VbCallRun Function
- Last UpdatedJul 18, 2023
- 1 minute read
Used to execute the VBA function or subroutine (previously opened with the Cicode VbCallOpen function), and requires the handle returned from the VbCallOpen function call.
The VbCallRun function provides an opportunity for the opened VBA function to complete and return a value in the multi-threaded Plant SCADA environment. It passes its argument value (of OBJECT data type) through as its return value upon completion.
VbCallRun is used in conjunction with VbCallOpen and VbCallReturn functions, which can all be nested to implement the entire function set with a single line of Cicode. For details, see Calling VBA from Cicode in the topic Using VBA in Command or Expression Fields.
Syntax
ReturnValue = VbCallRun(CallHandle)
ReturnValue:
The handle to the opened VBA function passed in as CallHandle.
CallHandle:
The handle to the previously opened VBA function as returned by the VbCallOpen function.
Return Value
VbCallRun (passes through and) returns a Object data type containing a handle to the VBA function being called.
Related Functions
VbCallOpen Function| VbCallReturn Function
Example
FUNCTION
TestCitectVBA()
INT iRet;
STRING sMsg = "Hello";
INT iVal = 123;
iRet = VbCallReturn(VbCallRun(VbCallOpen("CiVBATest",
iVal)));
Message("TestCitectVBA Function", "CiVBATest = " +
IntToStr(iRet), 0);
END
Example
Function CiVBATest(Value As Integer) As Integer
CiVBATest = Value * 2
End Function