|
Using Events in Visual Basic and Setting Other
Symbol Factory Properties from Code
The Symbol Factory Controls support the standard range of Visual Basic
events. You may use these events to trigger actions in your program. A common example might be to let someone click on a motor to send a value to the PLC to start the motor.
If you had a Symbol Factory Standard Control on a form with a motor image chosen as shown below:
1. Double click on the Symbol Factory Standard Control
2. The Visual Basic Code editor window appears and places you in the SFStandard1 Click event handler routine.

1. Enter your code in the subroutine for what you want to happen.
Private Sub SFStandard1_Click()
Enter your VB code here for the actions you want taken
When someone clicks on the control you placed on the form
End Sub
Example using Symbol Factory properties
- These examples also demonstrate setting the various properties available on the Style tab of the Symbol Factory Standard Control Property sheet from code rather than from the property sheet.
Example 1 When the user clicks on the motor, have it change colors from the default color to red shaded and back to the default in an alternating manner with each click.
Private Sub SFStandard1_Click()
If SFStandard1.FillColorMode = Original Then
SFStandard1.FillColorMode = Shaded
SFStandard1.FillColor = vbRed
Else
SFStandard1.FillColorMode = Original
End If
End Sub
Example 2 When the user clicks on the motor, have it stop blinking if it was already blinking or start blinking if it was stopped.
Private Sub SFStandard1_Click()
If SFStandard1.BlinkMode = NoBlink Then
SFStandard1.BlinkMode = BlinkShaded
SFStandard1.BlinkColor = vbRed
Else
SFStandard1.BlinkMode = NoBlink
End If
End Sub
Previous - Digital Animation | Next - Tank with cutaway fill
|