Applies to:
PcVue all versions. |
||
|
||
Summary:
By forcing a variable in VBA code you can trigger a SCADA Basic function. By forcing a variable in SCADA Basic you can trigger a VBA procedure. |
||
|
||
Details:
Example 1: Trigger a SCADA Basic function using a VBA procedure. The process is that the VBA procedure is used to force the value of a text variable which triggers the SCADA Basic function using an event. The text variable contents is used to define the SCADA Basic program parameters. ‘************************************************************* Sub FromVBA() Dim sMessage as str; sMessage = @GENERAL.SCADA_BASIC.FROM_VBA; if (!cmpstring(sMessage,””)) then hbuf = alloc_buffer(1000); print(“Init(FromVBA)- Prog:”,Prog,” -Proc:”,Proc,” -Br:”,Br,” -Arg:”,Arg); program(“FUNCTION”,Prog,Br,Proc,Arg); @GENERAL.SCADA_BASIC.FROM_VBA = “”; End Sub Example 2: Trigger a VBA procedure from SCADA Basic. The process is that SCADA Basic is used to force the value of a variable which triggers a VBA value change event. (Variable must be subscribed.) ‘Variable declaration Private WithEvents vFromScadaBasic As Variable ‘Database variables initialization ‘Variable subscription End Sub ‘———————————————– ‘Function : vFromScadaBasic_ValueChange ‘———————————————– Private Sub vFromScadaBasic_ValueChange() Dim vtArrayTmp As Variant If [GENERAL.SCADA_BASIC.TO_VBA] = “” Then Exit Sub vtArrayTmp = Split(vFromScadaBasic.Value, “$”) Select Case UCase(vtArrayTmp(0)) ‘ActionType [GENERAL.SCADA_BASIC.TO_VBA] = “” On Error GoTo 0 End Sub |
||
|
||
|
Created on: 23 Dec 2010 Last update: 13 May 2024