Appendix – Lenze VisiWinNet VisiWinNET Smart Benutzerhandbuch
Seite 254

Appendix
Scripts
Basics
l
254
SHP−VWNS DE/EN 6.1
Inserting a frame function
By selecting an event name on the right a frame function is inserted.
Example of an event frame function:
Private Sub VarIn1_Change(ByVal sender As System.Object, _
ByVal e As VisiWinNET.DataAccess.ChangeEventArgs) Handles VarIn1.Change
End Sub
The selected object "VarIn1" provides the "Change" event which signalises the change of
the variable value. For inserting the function the object "VarIn1" was selected in the
selection list on the left, afterwards in the "Change" selection list on the right.
The function button of the frame function inserted contains the following:
ƒ
A name for the function ("VarIn1_Change"). The name has to be unambiguous
within a code module.
ƒ
The parameters "sender" and "e"; "sender" usually being a reference to the object
within which the event has been triggered. "e" usually contains further information
with regard to the event.
ƒ
The "Handles" condition describes the objects and events by which the function is
triggered. In this case this is only a Change event of VarIn1. However, you can switch
further events with identical parameters to the function by adding further event
identifiers (<Object name>.<Event name>), separated by commas, to the "Handles"
condition. In this case it becomes clear why the "Sender" parameter is included in
the function. Via "Sender" the object which has triggered this event can then be
determined.
The function end is represented by "End Sub". Between the function head and the function
end the executable VB code is permissible:
Private Sub VarIn1_Change(ByVal sender As System.Object, _
ByVal e As VisiWinNET.DataAccess.ChangeEventArgs) Handles VarIn1.Change
If e.Value > 50 Then
VarIn1.DataBackColor = System.Drawing.Color.Red
Else
VarIn1.DataBackColor = System.Drawing.SystemColors.Window
End If
End Sub
Example: Within the e−argument further information with regard to the event is provided.
Here the background colour in the data area of "VarIn1" is switched over on the basis of the
value property from the variable core.
Help for the creation of scripts
VisiWinNET
â
Smart contains programming interfaces for the surface elements and the
underlying system.
You can obtain information in brief form about the functions
(properties/methods/events) provided by an object by means of the Intellisense window
which is implemented in the source code editor and which opens automatically when
object names or name areas are entered (the use of upper/lower case is important!).